From: Andre McCurdy <armccurdy@gmail.com>
To: musl@lists.openwall.com
Cc: Andre McCurdy <armccurdy@gmail.com>
Subject: [PATCH] drop unused extra char from getnameinfo() local buffer
Date: Thu, 27 Jun 2019 17:54:33 -0700 [thread overview]
Message-ID: <1561683273-18265-1-git-send-email-armccurdy@gmail.com> (raw)
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
next reply other threads:[~2019-06-28 0:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 0:54 Andre McCurdy [this message]
2019-06-28 15:13 ` Rich Felker
2019-06-28 19:24 ` Andre McCurdy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1561683273-18265-1-git-send-email-armccurdy@gmail.com \
--to=armccurdy@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).