]> granicus.if.org Git - php/commitdiff
char **error_message was passed but not used. This causes problems in cases
authorAndrey Hristov <andrey@php.net>
Mon, 10 Mar 2008 19:55:43 +0000 (19:55 +0000)
committerAndrey Hristov <andrey@php.net>
Mon, 10 Mar 2008 19:55:43 +0000 (19:55 +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 f812133efa6563cb479d25eda76838d38c9a9214..d60aa8de84226b0ee2490460a2f2cbef3037db0a 100644 (file)
@@ -205,10 +205,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;
        }
 
@@ -232,7 +234,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 fa7321462fd1a5ee3150e019384f36eb738d9739..737f9d821a334a48754ab487cc438245b5e5a646 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;