]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/tape: Use scnprintf() instead of sprintf()
authorHeiko Carstens <hca@linux.ibm.com>
Tue, 7 Oct 2025 09:05:04 +0000 (11:05 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 21 Oct 2025 08:17:30 +0000 (10:17 +0200)
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 <hoeppner@linux.ibm.com>
Reviewed-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/char/tape_char.c

index 89778d922d9f021177237b11af1b28ec5c226b2f..058a3b95f959535c26e7098f48761655be27285f 100644 (file)
@@ -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),