|
Message-Id: <1561683273-18265-1-git-send-email-armccurdy@gmail.com> Date: Thu, 27 Jun 2019 17:54:33 -0700 From: Andre McCurdy <armccurdy@...il.com> To: musl@...ts.openwall.com Cc: Andre McCurdy <armccurdy@...il.com> Subject: [PATCH] drop unused extra char from getnameinfo() local buffer The num local buffer is only passed to itoa(), which expects a buffer size of 3*sizeof(int), not 3*sizeof(int)+1. Also change the data type of the port local variable to clarify that itoa() only handles unsigned values. --- src/network/getnameinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c index f77e73a..02c2c09 100644 --- a/src/network/getnameinfo.c +++ b/src/network/getnameinfo.c @@ -124,7 +124,7 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl, int flags) { char ptr[PTR_MAX]; - char buf[256], num[3*sizeof(int)+1]; + char buf[256], num[3*sizeof(int)]; int af = sa->sa_family; unsigned char *a; unsigned scopeid; @@ -184,7 +184,7 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl, if (serv && servlen) { char *p = buf; - int port = ntohs(((struct sockaddr_in *)sa)->sin_port); + unsigned port = ntohs(((struct sockaddr_in *)sa)->sin_port); buf[0] = 0; if (!(flags & NI_NUMERICSERV)) reverse_services(buf, port, flags & NI_DGRAM); -- 1.9.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.