summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2018-05-15 15:31:00 +0800
committerThomas Monjalon <thomas@monjalon.net>2018-05-15 15:19:13 +0200
commit52f711f7b827ef5de0f6bd30066b9125d35c7ba6 (patch)
tree02887d9674defc94047eaea4574d91f84f4e85b9
parentff75dd7d651e71213074a18e4a93e1ba612e84f7 (diff)
downloaddpdk-52f711f7b827ef5de0f6bd30066b9125d35c7ba6.zip
dpdk-52f711f7b827ef5de0f6bd30066b9125d35c7ba6.tar.gz
dpdk-52f711f7b827ef5de0f6bd30066b9125d35c7ba6.tar.xz
bus/pci: fix size of driver name buffer
Variable dri_name is a pointer and it is incorrect to use its size as the buffer size. Caller knows the buffer size and it is safer to pass it explicitly. Fixes: fe5f777b5383 ("bus/pci: replace strncpy by strlcpy") Cc: stable@dpdk.org Signed-off-by: Andy Green <andy@warmcat.com> Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
-rw-r--r--drivers/bus/pci/linux/pci.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index a73ee49..004600f 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -33,7 +33,8 @@
extern struct rte_pci_bus rte_pci_bus;
static int
-pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
+pci_get_kernel_driver_by_path(const char *filename, char *dri_name,
+ size_t len)
{
int count;
char path[PATH_MAX];
@@ -54,7 +55,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
name = strrchr(path, '/');
if (name) {
- strlcpy(dri_name, name + 1, sizeof(dri_name));
+ strlcpy(dri_name, name + 1, len);
return 0;
}
@@ -314,7 +315,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
/* parse driver */
snprintf(filename, sizeof(filename), "%s/driver", dirname);
- ret = pci_get_kernel_driver_by_path(filename, driver);
+ ret = pci_get_kernel_driver_by_path(filename, driver, sizeof(driver));
if (ret < 0) {
RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
free(dev);