Use correct error string for getaddrinfo() and getnameinfo() failures.
authorMichael Poole <mdpoole@troilus.org>
Sun, 15 Jun 2008 13:23:22 +0000 (09:23 -0400)
committerMichael Poole <mdpoole@troilus.org>
Sun, 15 Jun 2008 13:23:22 +0000 (09:23 -0400)
src/ioset.c (ioset_connect): Include the error string when getaddrinfo()
  fails.
src/mail-smtp.c (smtp_fill_name): Use gai_strerror() rather than strerror().

src/ioset.c
src/mail-smtp.c

index ced561f72622fc82509a5298a28aa987949c0ef6..30eb359f816bac41731e7c093146de7326379eec 100644 (file)
@@ -267,8 +267,9 @@ ioset_connect(struct sockaddr *local, unsigned int sa_size, const char *peer, un
     hints.ai_family = local ? local->sa_family : 0;
     hints.ai_socktype = SOCK_STREAM;
     snprintf(portnum, sizeof(portnum), "%u", port);
-    if (getaddrinfo(peer, portnum, &hints, &ai)) {
-        log_module(MAIN_LOG, LOG_ERROR, "getaddrinfo(%s, %s) failed.", peer, portnum);
+    res = getaddrinfo(peer, portnum, &hints, &ai);
+    if (res != 0) {
+        log_module(MAIN_LOG, LOG_ERROR, "getaddrinfo(%s, %s) failed: %s.", peer, portnum, gai_strerror(res));
         return NULL;
     }
 
index 9ec083d0a31defd4b9c10beb9de98cfc3f608c13..b1b50955dc294296327b801b51b2ac4178e3ae6c 100644 (file)
@@ -138,7 +138,7 @@ static void smtp_fill_name(char *namebuf, size_t buflen)
     }
     res = getnameinfo(sa, sa_len, namebuf, buflen, NULL, 0, NI_NUMERICHOST);
     if (res != 0) {
-        log_module(MAIL_LOG, LOG_ERROR, "Unable to get text form of socket name: %s", strerror(errno));
+        log_module(MAIL_LOG, LOG_ERROR, "Unable to get text form of socket name: %s", gai_strerror(res));
     }
 }