[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <29717a11-8867-4a28-81a6-2d847b254042@suswa.mountain>
Date: Wed, 18 Jun 2025 23:42:15 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Pranav Tyagi <pranav.tyagi03@...il.com>
Cc: johan@...nel.org, elder@...nel.org, gregkh@...uxfoundation.org,
vireshk@...nel.org, greybus-dev@...ts.linaro.org,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
skhan@...uxfoundation.org, linux-kernel-mentees@...ts.linux.dev
Subject: Re: [PATCH] greybus: firmware: use strscpy, fix tag size
On Tue, Jun 17, 2025 at 06:21:37PM +0530, Pranav Tyagi wrote:
> Increase the size of firmware_tag arrays in the following structs from
> GB_FIRMWARE_U_TAG_MAX_SIZE to GB_FIRMWARE_U_TAG_MAX_SIZE + 1 to
> accommodate null termination:
> - fw_mgmt_ioc_intf_load_and_validate
> - fw_mgmt_ioc_get_backend_version
> - fw_mgmt_ioc_backend_fw_update
> - fw_mgmt_ioc_get_intf_version
>
> Replace strncpy() with strscpy() to ensure proper null termination as
> firmware_tag is interpreted as a null-terminated string
> and printed with %s.
>
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@...il.com>
> ---
> .../greybus/Documentation/firmware/firmware.c | 12 ++++++------
> drivers/staging/greybus/greybus_firmware.h | 8 ++++----
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c b/drivers/staging/greybus/Documentation/firmware/firmware.c
> index 765d69faa9cc..3b4061f4b34a 100644
> --- a/drivers/staging/greybus/Documentation/firmware/firmware.c
> +++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
> @@ -63,8 +63,8 @@ static int update_intf_firmware(int fd)
> intf_load.major = 0;
> intf_load.minor = 0;
>
> - strncpy((char *)&intf_load.firmware_tag, firmware_tag,
> - GB_FIRMWARE_U_TAG_MAX_SIZE);
> + strscpy((char *)&intf_load.firmware_tag, firmware_tag,
> + GB_FIRMWARE_U_TAG_MAX_SIZE + 1);
This is in the Documentation/ directory. It's sample userspace
code. Userspace code doesn't have strscpy() so this won't
compile.
regards,
dan carpenter
Powered by blists - more mailing lists