From: Andy Green Date: Mon, 14 May 2018 05:00:06 +0000 (+0800) Subject: bus/pci: replace strncpy by strlcpy X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fe5f777b538301ecadf3fee5c30dd0b289f50c7c;p=dpdk.git bus/pci: replace strncpy by strlcpy In function ‘pci_get_kernel_driver_by_path’, inlined from ‘pci_scan_one.isra.1’ at drivers/bus/pci/linux/pci.c:317:8: drivers/bus/pci/linux/pci.c:57:3: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy(dri_name, name + 1, strlen(name + 1) + 1); Fixes: d9a8cd9595f2 ("pci: add kernel driver type") Cc: stable@dpdk.org Signed-off-by: Andy Green Acked-by: Pablo de Lara --- diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 4630a8057f..a73ee49c2f 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name) name = strrchr(path, '/'); if (name) { - strncpy(dri_name, name + 1, strlen(name + 1) + 1); + strlcpy(dri_name, name + 1, sizeof(dri_name)); return 0; }