n64cart: use strscpy in n64cart_probe
PATCH RESEND 1/1 n64cart: use strscpy in n64cart_probe
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
--- drivers/block/n64cart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/n64cart.c +2 -1
@@ -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 );
Gentle ping?
Quoted 33 lines · Thorsten Blum
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, replacestrcpy()with the saferstrscpy()to follow secure coding best practices.[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by Thorsten Blum <[email protected]>--- drivers/block/n64cart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/block/n64cart.c +2
-1@@ -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 );
Quoted 8 lines · Thorsten Blum
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, replacestrcpy()with the saferstrscpy()to follow secure coding best practices.[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
[...]
Applied, thanks!
[1/1] n64cart: use strscpy in n64cart_probe
commit: 3f1eccd37282de91efd0575ee8e212af4bde39b1
Best regards,
Signature · 1 line
Jens Axboe