Skip to content

Commit d925ac5

Browse files
tobluxkawasaki
authored andcommitted
n64cart: use strscpy() in n64cart_probe
strcpy() has been deprecated¹ 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. ¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy Signed-off-by: Thorsten Blum <[email protected]>
1 parent 857ada9 commit d925ac5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/block/n64cart.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/init.h>
1313
#include <linux/module.h>
1414
#include <linux/platform_device.h>
15+
#include <linux/string.h>
1516

1617
enum {
1718
PI_DRAM_REG = 0,
@@ -145,7 +146,7 @@ static int __init n64cart_probe(struct platform_device *pdev)
145146
disk->flags = GENHD_FL_NO_PART;
146147
disk->fops = &n64cart_fops;
147148
disk->private_data = &pdev->dev;
148-
strcpy(disk->disk_name, "n64cart");
149+
strscpy(disk->disk_name, "n64cart");
149150

150151
set_capacity(disk, size >> SECTOR_SHIFT);
151152
set_disk_ro(disk, 1);

0 commit comments

Comments
 (0)