linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] leds: mlxreg: Fix possible buffer overflow
@ 2019-09-03 12:50 Oleh Kravchenko
  2019-09-03 12:50 ` [PATCH 2/2] leds: ns2: Fix wrong boolean expression Oleh Kravchenko
  2019-09-03 14:12 ` [PATCH 1/2] leds: mlxreg: Fix possible buffer overflow Pavel Machek
  0 siblings, 2 replies; 11+ messages in thread
From: Oleh Kravchenko @ 2019-09-03 12:50 UTC (permalink / raw)
  To: linux-leds; +Cc: Oleh Kravchenko

Error was detected by PVS-Studio:
V512 A call of the 'sprintf' function will lead to overflow of
the buffer 'led_data->led_cdev_name'.

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
---
 drivers/leds/leds-mlxreg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
index cabe379071a7..82aea1cd0c12 100644
--- a/drivers/leds/leds-mlxreg.c
+++ b/drivers/leds/leds-mlxreg.c
@@ -228,8 +228,8 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
 			brightness = LED_OFF;
 			led_data->base_color = MLXREG_LED_GREEN_SOLID;
 		}
-		sprintf(led_data->led_cdev_name, "%s:%s", "mlxreg",
-			data->label);
+		snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name),
+			 "mlxreg:%s", data->label);
 		led_cdev->name = led_data->led_cdev_name;
 		led_cdev->brightness = brightness;
 		led_cdev->max_brightness = LED_ON;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-09-08  8:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 12:50 [PATCH 1/2] leds: mlxreg: Fix possible buffer overflow Oleh Kravchenko
2019-09-03 12:50 ` [PATCH 2/2] leds: ns2: Fix wrong boolean expression Oleh Kravchenko
2019-09-03 14:12   ` Pavel Machek
2019-09-03 16:00     ` Oleh Kravchenko
2019-09-03 18:50       ` Pavel Machek
2019-09-03 19:46         ` Oleh Kravchenko
2019-09-03 21:02         ` Oleh Kravchenko
2019-09-03 14:12 ` [PATCH 1/2] leds: mlxreg: Fix possible buffer overflow Pavel Machek
2019-09-03 18:11   ` Oleh Kravchenko
2019-09-07 19:36     ` Pavel Machek
2019-09-08  8:57       ` Oleh Kravchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).