tony2001                Tue Mar 11 10:27:10 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/main       network.c 
  Log:
  MFH: fix segfault - error_string may be NULL, in this case we have to follow 
the old behavior
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.118.2.2.2.6.2.5&r2=1.118.2.2.2.6.2.6&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.118.2.2.2.6.2.5 
php-src/main/network.c:1.118.2.2.2.6.2.6
--- php-src/main/network.c:1.118.2.2.2.6.2.5    Mon Mar 10 19:54:47 2008
+++ php-src/main/network.c      Tue Mar 11 10:27:10 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: network.c,v 1.118.2.2.2.6.2.5 2008/03/10 19:54:47 andrey Exp $ */
+/* $Id: network.c,v 1.118.2.2.2.6.2.6 2008/03/11 10:27:10 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -205,12 +205,20 @@
 # endif
                
        if ((n = getaddrinfo(host, NULL, &hints, &res))) {
-               spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+               if (error_string) {
+                       spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+               } else {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+               }
                return 0;
        } else if (res == NULL) {
-               spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed (null result pointer) errno=%d", errno);
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+               if (error_string) {
+                       spprintf(error_string, 0, "php_network_getaddresses: 
getaddrinfo failed (null result pointer) errno=%d", errno);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+               } else {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: getaddrinfo failed (null result pointer)");
+               }
                return 0;
        }
 
@@ -234,8 +242,12 @@
                /* XXX NOT THREAD SAFE (is safe under win32) */
                host_info = gethostbyname(host);
                if (host_info == NULL) {
-                       spprintf(error_string, 0, "php_network_getaddresses: 
gethostbyname failed. errno=%d", errno);
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
*error_string);
+                       if (error_string) {
+                               spprintf(error_string, 0, 
"php_network_getaddresses: gethostbyname failed. errno=%d", errno);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"%s", *error_string);
+                       } else {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"php_network_getaddresses: gethostbyname failed");
+                       }
                        return 0;
                }
                in = *((struct in_addr *) host_info->h_addr);



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

Reply via email to