X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=inline;f=lib%2Flibrte_pci%2Frte_pci.c;h=5f7726fa89d5038b1e4d0f9418359d1220d5ea82;hb=21a61fae51804cfdf7c6f7e6189c63f02025de89;hp=ad2cdfebb2b54f72155a03e9a6560e1889aa3049;hpb=26cfc20feddd9fc5b87842d4c9bda6b9453e2c46;p=dpdk.git diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c index ad2cdfebb2..5f7726fa89 100644 --- a/lib/librte_pci/rte_pci.c +++ b/lib/librte_pci/rte_pci.c @@ -35,6 +35,12 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm) if (*in == '\0') return NULL; + /* PCI field starting with spaces is forbidden. + * Negative wrap-around is not reported as an error by strtoul. + */ + if (*in == ' ' || *in == '-') + return NULL; + errno = 0; val = strtoul(in, &end, 16); if (errno != 0 || end[0] != dlm || val > UINT8_MAX) { @@ -70,6 +76,12 @@ pci_dbdf_parse(const char *input, struct rte_pci_addr *dev_addr) unsigned long val; char *end; + /* PCI id starting with spaces is forbidden. + * Negative wrap-around is not reported as an error by strtoul. + */ + if (*in == ' ' || *in == '-') + return -EINVAL; + errno = 0; val = strtoul(in, &end, 16); if (errno != 0 || end[0] != ':' || val > UINT32_MAX)