]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
n64cart: use strscpy in n64cart_probe
authorThorsten Blum <thorsten.blum@linux.dev>
Sun, 17 May 2026 17:26:17 +0000 (19:26 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 2 Jun 2026 23:43:32 +0000 (17:43 -0600)
strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. While the
current code works correctly, replace strcpy() with the safer strscpy()
to follow secure coding best practices.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260517172617.3954-2-thorsten.blum@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/n64cart.c

index b9fdeff31cafdf8ecb3477e8f8a729edb379668b..328da73b6f2cfed93f60aa92af23ca4c9d2c89bd 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/string.h>
 
 enum {
        PI_DRAM_REG = 0,
@@ -145,7 +146,7 @@ static int __init n64cart_probe(struct platform_device *pdev)
        disk->flags = GENHD_FL_NO_PART;
        disk->fops = &n64cart_fops;
        disk->private_data = &pdev->dev;
-       strcpy(disk->disk_name, "n64cart");
+       strscpy(disk->disk_name, "n64cart");
 
        set_capacity(disk, size >> SECTOR_SHIFT);
        set_disk_ro(disk, 1);