All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Dharanitharan R <dharanitharan725@gmail.com>
Cc: johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org,
	greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev
Subject: Re: [PATCH] staging: greybus: replace strncpy() with strlcpy() in firmware test tool
Date: Tue, 18 Nov 2025 10:36:50 +0300	[thread overview]
Message-ID: <aRwiEnEx4gX90eVh@stanley.mountain> (raw)
In-Reply-To: <20251117065003.7453-1-dharanitharan725@gmail.com>

On Mon, Nov 17, 2025 at 06:50:03AM +0000, Dharanitharan R wrote:
> The sample userspace firmware-management tool uses strncpy() to copy
> firmware tags. strncpy() does not guarantee null-termination and can
> leave buffers unterminated. For userspace code, strlcpy() is the
> recommended safe alternative.
> 
> Replace all strncpy() calls with strlcpy().

Don't use strlcpy().  Either use strscpy() or strscpy_pad() as
appropriate.  I wrote a blog about this which may be useful.

https://staticthinking.wordpress.com/2023/10/30/strcpy-strncpy-strlcpy-and-strscpy/

regards,
dan carpenter


      parent reply	other threads:[~2025-11-18  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17  6:50 [PATCH] staging: greybus: replace strncpy() with strlcpy() in firmware test tool Dharanitharan R
2025-11-17 12:33 ` Greg KH
2025-11-18  7:36 ` Dan Carpenter [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=aRwiEnEx4gX90eVh@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=dharanitharan725@gmail.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.