]> granicus.if.org Git - php/commitdiff
Fixed bug #46379 (Infinite loop when parsing '#' in one line file)
authorArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 23:26:24 +0000 (23:26 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Mon, 3 Nov 2008 23:26:24 +0000 (23:26 +0000)
# PHP_5_2 only

NEWS
sapi/cgi/cgi_main.c
sapi/cli/php_cli.c

diff --git a/NEWS b/NEWS
index 09c86a3bbec20404b15d9a3951049e75b889bf6d..622f5bb8ae389ecff878b1b63e6a732de6978461 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP                                                                        NEWS
 - Fixed bug #46406 (Unregistering nodeclass throws E_FATAL). (Rob)
 - Fixed bug #46389 (NetWare needs small patch for _timezone).
   (patch by guenter@php.net)
+- Fixed bug #46379 (Infinite loop when parsing '#' in one line file). (Arnaud)
 - Fixed bug #46388 (stream_notification_callback inside of object destroys 
   object variables). (Felipe)
 - Fixed bug #46381 (wrong $this passed to internal methods causes segfault). 
index de2718dbf567a16380dadd634963e7acf8ca7ceb..9d0b9746b6579b3c2c13dcbde094b44e62034460 100644 (file)
@@ -1964,7 +1964,7 @@ consult the installation file that came with this distribution, or visit \n\
                        /* #!php support */
                        c = fgetc(file_handle.handle.fp);
                        if (c == '#') {
-                               while (c != '\n' && c != '\r') {
+                               while (c != '\n' && c != '\r' && c != EOF) {
                                        c = fgetc(file_handle.handle.fp);       /* skip to end of line */
                                }
                                /* handle situations where line is terminated by \r\n */
index e3f35991131c66191600200740f887032b683809..86d7ed020954daa49a2563c830f6214c8b3de052 100644 (file)
@@ -562,7 +562,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
        /* #!php support */
        c = fgetc(file_handle->handle.fp);
        if (c == '#') {
-               while (c != '\n' && c != '\r') {
+               while (c != '\n' && c != '\r' && c != EOF) {
                        c = fgetc(file_handle->handle.fp);      /* skip to end of line */
                }
                /* handle situations where line is terminated by \r\n */