]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
Fix error handling for getaddrinfo().
authorSimon Ruderich <simon@ruderich.org>
Sun, 28 Jul 2013 04:32:40 +0000 (06:32 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sun, 28 Jul 2013 04:32:40 +0000 (06:32 +0200)
src/connection.c
tests/client.c

index 36e03048943f9d6bc00f6f3f342f74f845a54e32..f608339f8014ba0427f515c36a14f1d29a51e894 100644 (file)
@@ -770,7 +770,12 @@ static int connect_to_host(const char *hostname, const char *port) {
                           | AI_V4MAPPED;   /* support IPv4 through IPv6 */
     gai_return = getaddrinfo(hostname, port, &gai_hints, &gai_result);
     if (gai_return != 0) {
-        LOG_PERROR(LOG_WARNING, "connect_to_host(): getaddrinfo()");
+        if (gai_return == EAI_SYSTEM) {
+            LOG_PERROR(LOG_WARNING, "connect_to_host(): getaddrinfo()");
+        } else {
+            LOG(LOG_WARNING, "connect_to_host(): getaddrinfo(): %s",
+                             gai_strerror(gai_return));
+        }
         return -1;
     }
 
index f98711fa02ffbf09afbafad2ed6a9577b152984c..d4edf7f8ba6f911fe674c1d1a697e21eb8bb908b 100644 (file)
@@ -185,7 +185,12 @@ static int connect_to_host(const char *hostname, const char *port) {
                           | AI_V4MAPPED;   /* support IPv4 through IPv6 */
     gai_return = getaddrinfo(hostname, port, &gai_hints, &gai_result);
     if (gai_return != 0) {
-        perror("connect_to_host(): getaddrinfo()");
+        if (gai_return == EAI_SYSTEM) {
+            perror("connect_to_host(): getaddrinfo()");
+        } else {
+            fprintf(stderr, "connect_to_host(): getaddrinfo(): %s",
+                            gai_strerror(gai_return));
+        }
         return -1;
     }