iliaa           Sat Sep  7 17:57:12 2002 EDT

  Modified files:              
    /php4/ext/standard  http_fopen_wrapper.c 
  Log:
  Added a check to ensure user_agent header is not sent if user_agent value
  if blank.
  
  
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.45 
php4/ext/standard/http_fopen_wrapper.c:1.46
--- php4/ext/standard/http_fopen_wrapper.c:1.45 Sat Sep  7 16:58:30 2002
+++ php4/ext/standard/http_fopen_wrapper.c      Sat Sep  7 17:57:11 2002
@@ -18,7 +18,7 @@
    |          Wez Furlong <[EMAIL PROTECTED]>                          |
    +----------------------------------------------------------------------+
  */
-/* $Id: http_fopen_wrapper.c,v 1.45 2002/09/07 20:58:30 wez Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.46 2002/09/07 21:57:11 iliaa Exp $ */ 
 
 #include "php.h"
 #include "php_globals.h"
@@ -211,19 +211,23 @@
 #define _UA_HEADER "User-Agent: %s\r\n"
                char *ua;
                size_t ua_len;
-
+               
                ua_len = sizeof(_UA_HEADER) + strlen(ua_str);
-               ua = emalloc(ua_len + 1);
-               if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {
-                       ua[ua_len] = 0;
-                       php_stream_write(stream, ua, ua_len);
-               } else {
-                       php_error(E_WARNING, "Cannot construct User-agent header");
-               }
+               
+               /* ensure the header is only sent if user_agent is not blank */
+               if (ua_len > sizeof(_UA_HEADER)) {
+                       ua = emalloc(ua_len + 1);
+                       if ((ua_len = snprintf(ua, ua_len, _UA_HEADER, ua_str)) > 0) {
+                               ua[ua_len] = 0;
+                               php_stream_write(stream, ua, ua_len);
+                       } else {
+                               php_error(E_WARNING, "Cannot construct User-agent 
+header");
+                       }
 
-               if (ua) {
-                       efree(ua);
-               }
+                       if (ua) {
+                               efree(ua);
+                       }
+               }       
        }
 
        php_stream_write(stream, "\r\n", sizeof("\r\n")-1);
@@ -271,7 +275,7 @@
                }
        }
        
-       if( reqok ) {
+       if (reqok) {
                /* read past HTTP headers */
        
                http_header_line = emalloc(HTTP_HEADER_BLOCK_SIZE);



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

Reply via email to