From a6c5173d9cbddbe570bd782aa5494e570d74b5a5 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 20 Aug 2024 18:22:59 +0300 Subject: [PATCH] Fix logging with IPv6 address --- error.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/error.h b/error.h index 9eddcee..bd5e372 100644 --- a/error.h +++ b/error.h @@ -70,10 +70,12 @@ static inline const int unie(int e) #endif #define INIT_ADDR_STR(dst) \ - char ADDR_STR[INET_ADDRSTRLEN + 1]; \ + char ADDR_STR[INET6_ADDRSTRLEN]; \ + const char *p = 0; \ if (dst.sa.sa_family == AF_INET) \ - inet_ntop(AF_INET, &dst.in.sin_addr, ADDR_STR, sizeof(ADDR_STR)); \ + p = inet_ntop(AF_INET, &dst.in.sin_addr, ADDR_STR, sizeof(ADDR_STR)); \ else \ - inet_ntop(AF_INET6, &dst.in6.sin6_addr, ADDR_STR, sizeof(ADDR_STR)); + p = inet_ntop(AF_INET6, &dst.in6.sin6_addr, ADDR_STR, sizeof(ADDR_STR)); \ + if (!p) uniperror("inet_ntop"); #endif