Re: [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name
From: David Laight
Date: Mon May 04 2026 - 08:46:03 EST
On Mon, 4 May 2026 15:50:34 +0800
Zhang Xiaolei <zxl434815272@xxxxxxxxx> wrote:
> Replace strcpy() with strscpy() to avoid potential buffer overflow
> when copying the consumer string.
You ought to run code before submitting patches.
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);