drivers/staging/greybus/Documentation/firmware/firmware.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
To ensuring that the firmware_tag is properly null-terminated. When
copying firmware tag strings to prevent buffer overflows and ensure
data integrity.
The maximum size of tag is GB_FIRMWARE_U_TAG_MAX_SIZE = 10 bytes, and it
may or may not be NULL-terminated.
included in "greybus_firmware.h"
changes has been made at 3 positions:
1: update firmware tag
2: backend update firmware tag
3: backend update firmware tag with unipro
Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com>
---
drivers/staging/greybus/Documentation/firmware/firmware.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/Documentation/firmware/firmware.c
b/drivers/staging/greybus/Documentation/firmware/firmware.c
index 765d69faa..f37904b91 100644
--- a/drivers/staging/greybus/Documentation/firmware/firmware.c
+++ b/drivers/staging/greybus/Documentation/firmware/firmware.c
@@ -63,7 +63,7 @@ static int update_intf_firmware(int fd)
intf_load.major = 0;
intf_load.minor = 0;
- strncpy((char *)&intf_load.firmware_tag, firmware_tag,
+ strscpy((char *)&intf_load.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
ret = ioctl(fd, FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE, &intf_load);
@@ -101,7 +101,7 @@ static int update_backend_firmware(int fd)
/* Get Backend Firmware Version */
printf("Getting Backend Firmware Version\n");
- strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
+ strscpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_version:
@@ -129,7 +129,7 @@ static int update_backend_firmware(int fd)
/* Try Backend Firmware Update over Unipro */
printf("Updating Backend Firmware\n");
- strncpy((char *)&backend_update.firmware_tag, firmware_tag,
+ strscpy((char *)&backend_update.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_SIZE);
retry_fw_update:
--
2.43.0
On Sat, May 17, 2025 at 09:11:30AM +0530, rujra wrote: > To ensuring that the firmware_tag is properly null-terminated. When > copying firmware tag strings to prevent buffer overflows and ensure > data integrity. > > The maximum size of tag is GB_FIRMWARE_U_TAG_MAX_SIZE = 10 bytes, and it > may or may not be NULL-terminated. > included in "greybus_firmware.h" > > changes has been made at 3 positions: > 1: update firmware tag > 2: backend update firmware tag > 3: backend update firmware tag with unipro > > Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com> From doesn't match Signed-off-by line. The patch is corrupted and doesn't apply. Read the two paragraphs of Documentation/process/email-clients.rst. This is a usespace program so I don't think it has a strscpy() function. How did you compile this? regards, dan carpenter
Hi Dan, On Fri, May 23, 2025 at 1:49 PM Dan Carpenter <dan.carpenter@linaro.org> wrote: > > On Sat, May 17, 2025 at 09:11:30AM +0530, rujra wrote: > > To ensuring that the firmware_tag is properly null-terminated. When > > copying firmware tag strings to prevent buffer overflows and ensure > > data integrity. > > > > The maximum size of tag is GB_FIRMWARE_U_TAG_MAX_SIZE = 10 bytes, and it > > may or may not be NULL-terminated. > > included in "greybus_firmware.h" > > > > changes has been made at 3 positions: > > 1: update firmware tag > > 2: backend update firmware tag > > 3: backend update firmware tag with unipro > > > > Signed-off-by: Rujra Bhatt <braker.noob.kernel@gmail.com> > > From doesn't match Signed-off-by line. > > The patch is corrupted and doesn't apply. Read the two paragraphs of > Documentation/process/email-clients.rst. > > This is a usespace program so I don't think it has a strscpy() > function. How did you compile this? I mistakenly submitted the patch with a mismatched From: and Signed-off-by: line. I’ll correct the author information from now onwards patches by following the guidance in Documentation/process/email-clients.rst. Also, regarding the use of strscpy(): You're absolutely correct. It's a kernel-space function and not available in user space. That call shouldn’t have been there. I’ll replace it with a suitable userspace alternative, such as strncpy(), as earlier it was. Also I am not able to compile it properly. Will learn it the proper way, as I have tried to compile it via turning ON the kernel menuconfig for greybus support and --- [*]"Greybus Firmware Download Class driver" then compiled it using make and installed it, Also have not tested via "gcc -o firmware firmware.c". If you have any suggestions on how to compile or test this more effectively, I would really appreciate your guidance. Thank you so much for the feedback and review. Also sorry for my delayed response. regards, Rujra Bhatt
© 2016 - 2025 Red Hat, Inc.