]> granicus.if.org Git - php/commitdiff
char **error_string was passed but not used. This causes problems in cases
authorAndrey Hristov <andrey@php.net>
Mon, 10 Mar 2008 20:09:22 +0000 (20:09 +0000)
committerAndrey Hristov <andrey@php.net>
Mon, 10 Mar 2008 20:09:22 +0000 (20:09 +0000)
of getaddrinfo() failure, because the upper layers don't get the error.
initialize a variable because we were reading initialized in case of error.

main/network.c
main/streams/xp_socket.c

index ecbdc13ebb4272e3668aac1a069d581f134076f9..ac9f337c3b029c48dad621e42b99c60fd807bb73 100644 (file)
@@ -200,10 +200,12 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
 # endif
                
        if ((n = getaddrinfo(host, NULL, &hints, &res))) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+               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);
                return 0;
        } else if (res == NULL) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed (null result pointer)");
+               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);
                return 0;
        }
 
@@ -227,7 +229,8 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
                /* XXX NOT THREAD SAFE (is safe under win32) */
                host_info = gethostbyname(host);
                if (host_info == NULL) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: gethostbyname failed");
+                       spprintf(error_string, 0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
                        return 0;
                }
                in = *((struct in_addr *) host_info->h_addr);
index d40cfefe61374f4e3866b29a5a317e45ff61c2e9..3cdc91c45148ae146e6848db0e45c1a75ce8a855 100644 (file)
@@ -601,7 +601,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_
 {
        char *host = NULL, *bindto = NULL;
        int portno, bindport = 0;
-       int err;
+       int err = 0;
        int ret;
        zval **tmpzval = NULL;