From: Thomas Pornin Date: Sat, 12 Nov 2016 14:30:47 +0000 (+0100) Subject: Better handling of inet_ntop() failures (which should not happen in practice, since... X-Git-Tag: v0.4~59 X-Git-Url: https://bearssl.org/gitweb//home/git/?a=commitdiff_plain;h=16d0864818cdf24e4fb1d722fe71456c03e3fc17;p=BearSSL Better handling of inet_ntop() failures (which should not happen in practice, since we filter on address family, but let's be cautious). --- diff --git a/tools/client.c b/tools/client.c index 692b60f..7acfebf 100644 --- a/tools/client.c +++ b/tools/client.c @@ -70,7 +70,9 @@ host_connect(const char *host, const char *port, int verbose) addr = NULL; } if (addr != NULL) { - inet_ntop(p->ai_family, addr, tmp, sizeof tmp); + if (!inet_ntop(p->ai_family, addr, tmp, sizeof tmp)) { + strcpy(tmp, ""); + } } else { sprintf(tmp, "", (int)sa->sa_family); diff --git a/tools/server.c b/tools/server.c index 0af6b42..983fbe6 100644 --- a/tools/server.c +++ b/tools/server.c @@ -87,7 +87,9 @@ host_bind(const char *host, const char *port, int verbose) sa_len = p->ai_addrlen; } if (addr != NULL) { - inet_ntop(p->ai_family, addr, tmp, sizeof tmp); + if (!inet_ntop(p->ai_family, addr, tmp, sizeof tmp)) { + strcpy(tmp, ""); + } } else { sprintf(tmp, "", (int)sa->sa_family);