From: Bruce Richardson <bruce.richardson@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Subject: Re: [PATCH v2 5/5] vhost: use strlcpy instead of strncpy
Date: Fri, 20 Dec 2024 13:37:26 +0000 [thread overview]
Message-ID: <Z2VzFhYFlw-MDi2U@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20241219225253.782792-6-stephen@networkplumber.org>
On Thu, Dec 19, 2024 at 02:49:55PM -0800, Stephen Hemminger wrote:
> 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));
>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
prev parent reply other threads:[~2024-12-20 13:37 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 ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
2024-12-20 13:37 ` Bruce Richardson [this message]
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=Z2VzFhYFlw-MDi2U@bricha3-mobl1.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).