> 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 



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to