From: Simon Ruderich Date: Sun, 28 Jul 2013 04:32:40 +0000 (+0200) Subject: Fix error handling for getaddrinfo(). X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=1d507eaf013fdffb6c17f0f02f6ee9a91d44aa62;p=tlsproxy%2Ftlsproxy.git Fix error handling for getaddrinfo(). --- diff --git a/src/connection.c b/src/connection.c index 36e0304..f608339 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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; } diff --git a/tests/client.c b/tests/client.c index f98711f..d4edf7f 100644 --- a/tests/client.c +++ b/tests/client.c @@ -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; }