Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: pata_it821x: Replace deprecated strcpy with strscpy in it821x_display_disk

strcpy() is deprecated; use strscpy() instead.

Replace the hard-coded buffer size 8 with sizeof(mbuf) when using
snprintf() while we're at it.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Niklas Cassel <cassel@kernel.org>

authored by

Thorsten Blum and committed by
Niklas Cassel
4ea303d9 c9d869fb

+3 -2
+3 -2
drivers/ata/pata_it821x.c
··· 75 75 #include <linux/blkdev.h> 76 76 #include <linux/delay.h> 77 77 #include <linux/slab.h> 78 + #include <linux/string.h> 78 79 #include <scsi/scsi_host.h> 79 80 #include <linux/libata.h> 80 81 ··· 633 632 cbl = ""; 634 633 635 634 if (mode) 636 - snprintf(mbuf, 8, "%5s%d", mtype, mode - 1); 635 + snprintf(mbuf, sizeof(mbuf), "%5s%d", mtype, mode - 1); 637 636 else 638 - strcpy(mbuf, "PIO"); 637 + strscpy(mbuf, "PIO"); 639 638 if (buf[52] == 4) 640 639 ata_port_info(ap, "%d: %-6s %-8s %s %s\n", 641 640 n, mbuf, types[buf[52]], id, cbl);