public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: gregkh@linuxfoundation.org, johan@kernel.org, elder@kernel.org,
	schopin@ubuntu.com, me@abhy.me, greybus-dev@lists.linaro.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: documentation: replace strncpy() with strscpy_pad()
Date: Tue, 14 Oct 2025 10:01:28 -0400	[thread overview]
Message-ID: <8918310c-d0aa-4e02-b9d4-9aac98b0a48f@gmail.com> (raw)
In-Reply-To: <aO5VvrKTswmfO-n9@stanley.mountain>

Yes, Dan. Nice catch. Building it with below sample change:

memset(&intf_load.firmware_tag, 0, GB_FIRMWARE_U_TAG_MAX_SIZE);
strncpy((char *)&intf_load.firmware_tag, firmware_tag,
         GB_FIRMWARE_U_TAG_MAX_SIZE - 1);

If it works, will send another patch.

Best, Vivek.


On 2025-10-14 9:53 a.m., Dan Carpenter wrote:
> On Tue, Oct 14, 2025 at 01:41:48PM +0000, Vivek BalachandharTN wrote:
>> strncpy() does not guarantee NUL-termination and is deprecated for
>> NUL-terminated strings. Replace it with strscpy_pad(), which guarantees
>> NUL-termination and zero-pads the remaining bytes, matching the fixed-size
>> firmware tag semantics.
>>
>> Signed-off-by: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
>> ---
>>   .../greybus/Documentation/firmware/firmware.c        | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/drivers/staging/greybus/Documentation/firmware/firmware.c
>> index 3b35ef6d4adb..deac8584841b 100644
>> --- a/drivers/staging/greybus/Documentation/firmware/firmware.c
>> +++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
> This is sample user space code so the strscpy_pad() isn't available.  It
> will break the compile.
>
> regards,
> dan carpenter
>

  reply	other threads:[~2025-10-14 14:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 13:41 [PATCH] staging: greybus: documentation: replace strncpy() with strscpy_pad() Vivek BalachandharTN
2025-10-14 13:53 ` Dan Carpenter
2025-10-14 14:01   ` Vivek BalachandharTN [this message]
2025-10-14 14:15     ` Dan Carpenter
2025-10-14 16:10       ` Vivek BalachandharTN
2025-10-14 17:13         ` Dan Carpenter
2025-10-14 23:53           ` Vivek BalachandharTN

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=8918310c-d0aa-4e02-b9d4-9aac98b0a48f@gmail.com \
    --to=vivek.balachandhar@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=me@abhy.me \
    --cc=schopin@ubuntu.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