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 12:10:50 -0400	[thread overview]
Message-ID: <8f550b4e-2b7e-4266-be92-bb724265949f@gmail.com> (raw)
In-Reply-To: <aO5a9izAISpCDJrc@stanley.mountain>

Hi Dan,

Thanks again—confirmed the structs are zero-initialized before the copy.

Would a minimal fix that guarantees NUL-termination be acceptable, e.g.:

strncpy((char *)&intf_load.firmware_tag, firmware_tag,
         GB_FIRMWARE_U_TAG_MAX_SIZE - 1);
((char *)&intf_load.firmware_tag)[GB_FIRMWARE_U_TAG_MAX_SIZE - 1] = '\0';

I can respin as v2 with the same change applied to the other two 
firmware_tag
fields.

Best regards,
Vivek

On 2025-10-14 10:15 a.m., Dan Carpenter wrote:
> On Tue, Oct 14, 2025 at 10:01:28AM -0400, Vivek BalachandharTN wrote:
>> 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);
> There isn't a need to doing the memset()...
>
> regards,
> dan carpenter
>

  reply	other threads:[~2025-10-14 16:10 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
2025-10-14 14:15     ` Dan Carpenter
2025-10-14 16:10       ` Vivek BalachandharTN [this message]
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=8f550b4e-2b7e-4266-be92-bb724265949f@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