Skip to content

Commit af0afc0

Browse files
tdns: strerror() -> strerror_r()
1 parent 4c42116 commit af0afc0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/dns.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,12 @@ void *thread_dns_ipbyhost(void *arg)
563563
}
564564
else if (error == EAI_NONAME)
565565
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): not known");
566-
else if (error == EAI_SYSTEM)
567-
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), strerror(errno));
568-
else
566+
else if (error == EAI_SYSTEM) {
567+
char ebuf[2048];
568+
if (strerror_r(errno, ebuf, sizeof ebuf))
569+
strcpy(ebuf, "strerror_r()");
570+
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), ebuf);
571+
} else
569572
snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s", gai_strerror(error));
570573
pthread_mutex_lock(&dtn->mutex);
571574
close(dtn->fildes[1]);

0 commit comments

Comments
 (0)