From af0afc08b419687645634640c2ef647b694c6223 Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Mon, 17 Jun 2024 01:21:27 +0200 Subject: [PATCH] tdns: strerror() -> strerror_r() --- src/dns.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dns.c b/src/dns.c index 69b3a03e5..32bc53849 100644 --- a/src/dns.c +++ b/src/dns.c @@ -563,9 +563,12 @@ void *thread_dns_ipbyhost(void *arg) } else if (error == EAI_NONAME) snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): not known"); - else if (error == EAI_SYSTEM) - snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), strerror(errno)); - else + else if (error == EAI_SYSTEM) { + char ebuf[2048]; + if (strerror_r(errno, ebuf, sizeof ebuf)) + strcpy(ebuf, "strerror_r()"); + snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s: %s", gai_strerror(error), ebuf); + } else snprintf(dtn->strerror, sizeof dtn->strerror, "dns: thread_dns_ipbyhost(): getaddrinfo(): %s", gai_strerror(error)); pthread_mutex_lock(&dtn->mutex); close(dtn->fildes[1]);