Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45520 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20190 invoked from network); 8 Sep 2009 15:39:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2009 15:39:50 -0000 X-Host-Fingerprint: 85.21.236.169 xdmitri.static.corbina.ru Received: from [85.21.236.169] ([85.21.236.169:19481] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/C1-09918-3CA76AA4 for ; Tue, 08 Sep 2009 11:39:49 -0400 Message-ID: To: internals@lists.php.net References: <20090904081640.GA28685@joeysmith.com> <4AA25E16.7040803@sci.fi> <30CAA781-B1EE-44E0-AC7B-47FF3DF48FE1@tabini.ca> <698DE66518E7CA45812BD18E807866CE03415400@us-ex1.zend.net> <99cf22520909080356q4e530e1bwd2e4536b94b5f023@mail.gmail.com> Date: Tue, 8 Sep 2009 19:39:45 +0400 Lines: 35 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Original X-Posted-By: 85.21.236.169 Subject: Re: [PHP-DEV] shebang skipping in 5.3.0 From: dmda@yandex.ru ("jvlad") > Hi, > Can this snippet of shebang checking be removed for php 5.3.+, 6? > Its for external FPM project. > > cgi_main.c: > php_fopen_primary_script(&file_handle TSRMLS_CC); > > if (CGIG(check_shebang_line) && file_handle.handle.fp && > (file_handle.handle.fp != stdin)) { > /* #!php support */ > c = fgetc(file_handle.handle.fp); /* <------- SEGFAULT */ Hi dreamcat four, Before accessing .handle.fp, you'd check type field It can be either ZEND_HANDLE_FILENAME, or ZEND_HANDLE_FD, or ZEND_HANDLE_FP, or finally ZEND_HANDLE_STREAM. in case of ZEND_HANDLE_STREAM you'd avoid accessing .fp field. in case of ZEND_HANDLE_FD, you deal with file descriptor (int), in case of ZEND_HANDLE_FP, you deal with FILE* handle in the .fp field, in case of ZEND_HANDLE_FILENAME you have only filename and you can open it using zend_stream_open() (or zend_fopen in case of php4). Regarding shebang checks to be removed or not, it's up to Andi and Dmitry. They are making decision whether this check should be done in the lexer or in SAPI. In former case, you'd remove the check, and leave it otherwise. Regards, jv