From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH] Removed warnings in nfs_sockaddr2universal()
Date: Thu, 28 May 2026 15:19:22 -0400 [thread overview]
Message-ID: <20260528191922.67906-1-steved@redhat.com> (raw)
in function 'nfs_sockaddr2universal',
inlined from 'nsm_xmit_getaddr.constprop' at ../../support/nsm/rpc.c:251:17:
../../support/nfs/getport.c:459:24: warning: 'strndup' specified bound 108 exceeds source size 26 [-Wstringop-overread]
459 | return strndup(sun->sun_path, sizeof(sun->sun_path));
| ^
Signed-off-by: Steve Dickson <steved@redhat.com>
---
This is a chatgpt solution to remove the warning... untested (yet)
---
support/nfs/getport.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/support/nfs/getport.c b/support/nfs/getport.c
index 813f7bf9..608e185b 100644
--- a/support/nfs/getport.c
+++ b/support/nfs/getport.c
@@ -452,11 +452,12 @@ char *nfs_sockaddr2universal(const struct sockaddr *sap)
uint16_t port;
size_t count;
char *result;
- int len;
+ int len = sizeof(struct sockaddr);
switch (sap->sa_family) {
case AF_LOCAL:
- return strndup(sun->sun_path, sizeof(sun->sun_path));
+ size_t path_len = len - offsetof(struct sockaddr_un, sun_path);
+ return strndup(sun->sun_path, path_len);
case AF_INET:
if (inet_ntop(AF_INET, (const void *)&sin->sin_addr.s_addr,
buf, (socklen_t)sizeof(buf)) == NULL)
--
2.54.0
next reply other threads:[~2026-05-28 19:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 19:19 Steve Dickson [this message]
2026-05-30 21:07 ` [PATCH] Removed warnings in nfs_sockaddr2universal() Steve Dickson
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=20260528191922.67906-1-steved@redhat.com \
--to=steved@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox