Skip to content

Commit 3ae08e4

Browse files
arndbBartosz Golaszewski
authored andcommitted
gpio: virtuser: avoid non-constant format string
Using a string variable as an sprintf format is potentially dangerous, and gcc can warn about this: drivers/gpio/gpio-virtuser.c: In function 'gpio_virtuser_dbgfs_init_line_attrs': drivers/gpio/gpio-virtuser.c:808:9: error: format not a string literal and no format arguments [-Werror=format-security] 808 | sprintf(data->consumer, id); | ^~~~~~~ Change it to a simpler strscpy() instead to just copy it and check the destination buffer size. Fixes: 91581c4 ("gpio: virtuser: new virtual testing driver for the GPIO API") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Link: https://lore.kernel.org/r/20240719144422.2082394-1-arnd@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent b3c0ecc commit 3ae08e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpio-virtuser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int gpio_virtuser_dbgfs_init_line_attrs(struct device *dev,
805805
return -ENOMEM;
806806

807807
data->ad.desc = desc;
808-
sprintf(data->consumer, id);
808+
strscpy(data->consumer, id);
809809
atomic_set(&data->irq, 0);
810810
atomic_set(&data->irq_count, 0);
811811

0 commit comments

Comments
 (0)