diff options
author | Steven Luong <sluong@cisco.com> | 2019-08-21 11:35:27 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-09-25 22:03:11 +0000 |
commit | 00127d69996792e8ea120df5915a61f808904335 (patch) | |
tree | c0d754d9af1105a5dbe11417d9e6009c22d4b8a9 | |
parent | 7cd964ee45e845e0f02d9dbcecc3c1cc9088e447 (diff) |
vlib: fix null pointer crash on strncmp
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4b71de0 in __strncmp_sse42 () from /lib64/libc.so.6
(gdb) up
up
vm=0x7ffff6664d40 <vlib_global_main>, addr=0x7fffb4bec6d0,
ids=0x7fffb31675f0 <avf_pci_device_ids>, handle=0x7fffb4bec594)
at /usr/src/debug/vpp-20.01/src/vlib/linux/pci.c:1250
1250 if (strncmp ("vfio-pci", (char *) di->driver_name, 8) == 0)
(gdb) p di
p di
$1 = (vlib_pci_device_info_t *) 0x7fffb6446164
(gdb) p di->driver_name
p di->driver_name
$2 = (u8 *) 0x0
(gdb)
driver_name may be null. strncmp is not forgiving. Change to use C11 safeC
version.
Type: fix
Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I1777a5966ceee7409d7bde86c30b14dc75534a5a
(cherry picked from commit ab4899257a77edecfbf9a97cf67acc26a2133119)
-rw-r--r-- | src/vlib/linux/pci.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index 20d44cd6d6e..fdb5271f56a 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -1247,9 +1247,9 @@ vlib_pci_device_open (vlib_main_t * vm, vlib_pci_addr_t * addr, di->vendor_id, di->device_id, di->driver_name, di->iommu_group); - if (strncmp ("vfio-pci", (char *) di->driver_name, 8) == 0) + if (clib_strncmp ("vfio-pci", (char *) di->driver_name, 8) == 0) err = add_device_vfio (vm, p, di, 0); - else if (strncmp ("uio_pci_generic", (char *) di->driver_name, 8) == 0) + else if (clib_strncmp ("uio_pci_generic", (char *) di->driver_name, 8) == 0) err = add_device_uio (vm, p, di, 0); else err = clib_error_create ("device not bound to 'vfio-pci' or " |