bus/pci: replace strncpy by strlcpy
authorAndy Green <andy@warmcat.com>
Mon, 14 May 2018 05:00:06 +0000 (13:00 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:32:23 +0000 (23:32 +0200)
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 <andy@warmcat.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
drivers/bus/pci/linux/pci.c

index 4630a80..a73ee49 100644 (file)
@@ -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;
        }