[PATCH v2 1/3] tools: gpio: use strscpy() for consumer name
From: Zhang Xiaolei
Date: Mon May 04 2026 - 03:55:54 EST
Replace strcpy() with strscpy() to avoid potential buffer overflow
when copying the consumer string.
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);
--
2.34.1