From c769941de8bf6ab744bbc7ec7a88c32955d10646 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Tue, 7 Oct 2025 11:05:04 +0200 Subject: [PATCH] s390/tape: Use scnprintf() instead of sprintf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use scnprintf() instead of sprintf() for those cases where the destination is an array and the size of the array is known at compile time. This prevents theoretical buffer overflows, but also avoids that people again and again spend time to figure out if the code is actually safe. Reviewed-by: Jan Höppner Reviewed-by: Jan Polensky Signed-off-by: Heiko Carstens --- drivers/s390/char/tape_char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c index 89778d922d9f0..058a3b95f9595 100644 --- a/drivers/s390/char/tape_char.c +++ b/drivers/s390/char/tape_char.c @@ -64,7 +64,7 @@ tapechar_setup_device(struct tape_device * device) { char device_name[20]; - sprintf(device_name, "ntibm%i", device->first_minor / 2); + scnprintf(device_name, sizeof(device_name), "ntibm%i", device->first_minor / 2); device->nt = register_tape_dev( &device->cdev->dev, MKDEV(tapechar_major, device->first_minor), -- 2.47.3