From: Heiko Carstens Date: Tue, 7 Oct 2025 09:05:04 +0000 (+0200) Subject: s390/tape: Use scnprintf() instead of sprintf() X-Git-Tag: v6.19-rc1~206^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c769941de8bf6ab744bbc7ec7a88c32955d10646;p=thirdparty%2Flinux.git s390/tape: Use scnprintf() instead of sprintf() 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 --- 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),