iliaa           Wed Dec  7 21:54:28 2005 EDT

  Modified files:              (Branch: PHP_4_4)
    /php-src    NEWS 
    /php-src/ext/standard       http_fopen_wrapper.c 
  Log:
  MFH: Fixed bug #34359 (Possible crash inside fopen http wrapper).
  
  
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.920.2.95&r2=1.1247.2.920.2.96&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.920.2.95 php-src/NEWS:1.1247.2.920.2.96
--- php-src/NEWS:1.1247.2.920.2.95      Tue Dec  6 18:33:03 2005
+++ php-src/NEWS        Wed Dec  7 21:54:26 2005
@@ -10,6 +10,7 @@
 - Fixed bug #35278 (Multiple virtual() calls crash Apache 2 php module). (Ilia)
 - Fixed bug #35062 (socket_read() produces warnings on non blocking sockets).
   (Nuno, Ilia)
+- Fixed bug #34359 (Possible crash inside fopen http wrapper). (Ilia,Nuno,Sara)
 - Fixed bug #33153 (crash in mssql_next result). (Frank)
 - Fixed bug #32009 (crash when mssql_bind() is called more than once). (Frank)
 - Fixed bug #33963 (mssql_bind() fails on input parameters). (Frank)
http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.53.2.20.2.3&r2=1.53.2.20.2.4&ty=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.3 
php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.4
--- php-src/ext/standard/http_fopen_wrapper.c:1.53.2.20.2.3     Tue Dec  6 
14:25:12 2005
+++ php-src/ext/standard/http_fopen_wrapper.c   Wed Dec  7 21:54:27 2005
@@ -18,7 +18,7 @@
    |          Wez Furlong <[EMAIL PROTECTED]>                          |
    +----------------------------------------------------------------------+
  */
-/* $Id: http_fopen_wrapper.c,v 1.53.2.20.2.3 2005/12/06 19:25:12 pollita Exp $ 
*/ 
+/* $Id: http_fopen_wrapper.c,v 1.53.2.20.2.4 2005/12/08 02:54:27 iliaa Exp $ 
*/ 
 
 #include "php.h"
 #include "php_globals.h"
@@ -392,28 +392,16 @@
        
        http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE);
 
-       while (!body && !php_stream_eof(stream))        {
-               
-               if (php_stream_gets(stream, http_header_line, 
HTTP_HEADER_BLOCK_SIZE-1) != NULL)        {
-                       char *p;
-                       int found_eol = 0;
-                       int http_header_line_length;
-                       
-                       http_header_line[HTTP_HEADER_BLOCK_SIZE-1] = '\0';
-
-                       p = http_header_line;
-                       while(*p) {
-                               while(*p == '\n' || *p == '\r') {
-                                       *p = '\0';
-                                       p--;
-                                       found_eol = 1;
-                               }
-                               if (found_eol)
-                                       break;
-                               p++;
+       while (!body && !php_stream_eof(stream)) {
+               size_t http_header_line_length;
+               if (php_stream_get_line(stream, http_header_line, 
HTTP_HEADER_BLOCK_SIZE, &http_header_line_length TSRMLS_CC) && 
*http_header_line != '\n' && *http_header_line != '\r') {
+                       char *e = http_header_line + http_header_line_length - 
1;
+                       while (*e == '\n' || *e == '\r') {
+                               e--;
                        }
-                       http_header_line_length = p-http_header_line+1;
-               
+                       http_header_line_length = e - http_header_line + 1;
+                       http_header_line[http_header_line_length] = '\0';
+
                        if (!strncasecmp(http_header_line, "Location: ", 10)) {
                                strlcpy(location, http_header_line + 10, 
sizeof(location));
                        } else if (!strncasecmp(http_header_line, 
"Content-Type: ", 14)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to