The function strtoul will not return ERANGE if the input is negative, as
one might expect.
0000:-
FFFFFFFFFFFFFFFB:00.0
is not a better way to write 0000:05:00.0.
To simplify checking for '-', forbid using spaces before the field value.
0000: 00: 2c.0
Should not be accepted.
Fixes:
af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Gaetan Rivet <grive@u256.net>
Acked-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
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) {
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)