nicvf_parse_devargs() uses atoi() on the skip_data_bytes value, which
cannot report an error, so a malformed value is silently taken as zero
and the argument is quietly ignored rather than rejected.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/thunderx/nicvf_ethdev.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
index 6e34da7c3c..7061def01a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -3,6 +3,7 @@
*/
#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
@@ -2161,9 +2162,17 @@ nicvf_set_first_skip(struct rte_eth_dev *dev)
for (i = 0; i != kvlist->count; ++i) {
const struct rte_kvargs_pair *pair = &kvlist->pairs[i];
+ uint64_t val;
- if (!strcmp(pair->key, SKIP_DATA_BYTES))
- bytes_to_skip = atoi(pair->value);
+ if (strcmp(pair->key, SKIP_DATA_BYTES))
+ continue;
+
+ if (rte_kvargs_to_uint(pair->value, 0, INT_MAX, &val) < 0) {
+ PMD_INIT_LOG(ERR, "skip_data_bytes is not a valid number");
+ ret = -EINVAL;
+ goto exit;
+ }
+ bytes_to_skip = val;
}
/*128 bytes amounts to one cache line*/--
2.53.0