]> www.infradead.org Git - users/jedix/linux-maple.git/commit
gpio: virtuser: avoid non-constant format string
authorArnd Bergmann <arnd@arndb.de>
Fri, 19 Jul 2024 14:44:10 +0000 (16:44 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 19 Jul 2024 14:56:27 +0000 (16:56 +0200)
commit3ae08e47742eeebf2190900d31ddac53fdd13a5b
tree145822a2ee899ba208df9949d7c3fcaf41df50ea
parentb3c0eccb485404d3ea5eaae483b1a2e9e2134d21
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: 91581c4b3f29 ("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>
drivers/gpio/gpio-virtuser.c