git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pci: reject negative values in PCI id
[dpdk.git]
/
lib
/
librte_pci
/
rte_pci.c
diff --git
a/lib/librte_pci/rte_pci.c
b/lib/librte_pci/rte_pci.c
index
ad2cdfe
..
5f7726f
100644
(file)
--- 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;
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) {
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;
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)
errno = 0;
val = strtoul(in, &end, 16);
if (errno != 0 || end[0] != ':' || val > UINT32_MAX)