Re: [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name
From: 007
Date: Wed May 06 2026 - 20:02:40 EST
OK, I will check it next time, thanks for the reminder.
Best regards
Zhang Xiaolei
On 5/4/26 20:45, David Laight wrote:
On Mon, 4 May 2026 15:50:34 +0800
Zhang Xiaolei <zxl434815272@xxxxxxxxx> wrote:
Replace strcpy() with strscpy() to avoid potential buffer overflowYou ought to run code before submitting patches.
when copying the consumer string.
This wasn't even compiled.
-- David
Signed-off-by: Zhang Xiaolei <zxl434815272@xxxxxxxxx>
---
tools/gpio/gpio-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
index 4096bcd511d1..176bccfcccb0 100644
--- a/tools/gpio/gpio-utils.c
+++ b/tools/gpio/gpio-utils.c
@@ -82,7 +82,7 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
req.offsets[i] = lines[i];
req.config = *config;
- strcpy(req.consumer, consumer);
+ strcpy(req.consumer, consumer, sizeof(req.consumer));
req.num_lines = num_lines;
ret = ioctl(fd, GPIO_V2_GET_LINE_IOCTL, &req);