summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-11-12 00:58:56 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-11-13 17:59:42 +0100
commit31f19a9beb8d88b67be6e469404081eb834d199c (patch)
treec51ec760290f6e23b41124d8d43470bb81b2980a
parent9eca8bd7a61cc3a0bd29e2ddd493915902bb98a5 (diff)
downloaddpdk-31f19a9beb8d88b67be6e469404081eb834d199c.zip
dpdk-31f19a9beb8d88b67be6e469404081eb834d199c.tar.gz
dpdk-31f19a9beb8d88b67be6e469404081eb834d199c.tar.xz
pci: fix parsing of address without function number
If the last part of the PCI address (function number) is missing, the parsing was successful, assuming function 0. The call to strtoul is not returning an error in such a case, so an explicit check is inserted before. This bug has always been there in older parsing macros: - GET_PCIADDR_FIELD - GET_BLACKLIST_FIELD Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Reported-by: Wisam Jaddo <wisamm@mellanox.com> Signed-off-by: Thomas Monjalon <thomas@monjalon.net> Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
-rw-r--r--lib/librte_pci/rte_pci.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c
index 530738d..f400178 100644
--- a/lib/librte_pci/rte_pci.c
+++ b/lib/librte_pci/rte_pci.c
@@ -30,6 +30,10 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm)
uint8_t *u8 = _u8;
char *end;
+ /* empty string is an error though strtoul() returns 0 */
+ if (*in == '\0')
+ return NULL;
+
errno = 0;
val = strtoul(in, &end, 16);
if (errno != 0 || end[0] != dlm || val > UINT8_MAX) {