From: Dan Carpenter <dan.carpenter@linaro.org>
To: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
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 20:13:45 +0300 [thread overview]
Message-ID: <aO6EyUVO9EOYfzV4@stanley.mountain> (raw)
In-Reply-To: <8f550b4e-2b7e-4266-be92-bb724265949f@gmail.com>
On Tue, Oct 14, 2025 at 12:10:50PM -0400, Vivek BalachandharTN wrote:
> 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.
Sorry, I should have explained this at the start... The struct is
initialized to zero. The strncpy() copies at most
"GB_FIRMWARE_U_TAG_MAX_SIZE - 1" characters, meaning we never copy
anything to the last character which stays as zero.
regards,
dan carpenter
next prev parent reply other threads:[~2025-10-14 17:13 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
2025-10-14 17:13 ` Dan Carpenter [this message]
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=aO6EyUVO9EOYfzV4@stanley.mountain \
--to=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 \
--cc=vivek.balachandhar@gmail.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