From fe5f777b538301ecadf3fee5c30dd0b289f50c7c Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 14 May 2018 13:00:06 +0800 Subject: [PATCH] bus/pci: replace strncpy by strlcpy MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- drivers/bus/pci/linux/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- 2.20.1