From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH v2 5/5] vhost: use strlcpy instead of strncpy
Date: Thu, 19 Dec 2024 14:49:55 -0800 [thread overview]
Message-ID: <20241219225253.782792-6-stephen@networkplumber.org> (raw)
In-Reply-To: <20241219225253.782792-1-stephen@networkplumber.org>
Some tools such as gcc address sanitizer will complain if strncpy
is used to completely fill a string since it will not be null
terminated. Since the previous code forced as null at end,
use strlcpy() to get the same effect.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/vhost/socket.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index d29d15494c..f938189cc2 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -359,8 +359,7 @@ create_unix_socket(struct vhost_user_socket *vsocket)
memset(un, 0, sizeof(*un));
un->sun_family = AF_UNIX;
- strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
- un->sun_path[sizeof(un->sun_path) - 1] = '\0';
+ strlcpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
vsocket->socket_fd = fd;
return 0;
--
2.45.2
next prev parent reply other threads:[~2024-12-19 22:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 17:05 [PATCH] bus/fslmc: fix use after rte_free Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 1/5] bus/fslmc: fix use after rte_free Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 2/5] net/bnxt: fix use after free Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 3/5] net/bnx2x: use RTE_BIT32 Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 4/5] net/qede: fix use after free Stephen Hemminger
2024-12-19 22:49 ` Stephen Hemminger [this message]
2024-12-20 13:37 ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Bruce Richardson
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=20241219225253.782792-6-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.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.
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).