hn_set_parameter() does not check errno, so an out of range value is
accepted as ULONG_MAX, and the result is stored into 32-bit fields
without any range check.
This also drops support for octal, which base 0 accepted; hexadecimal
still works.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/netvsc/hn_ethdev.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 9a193e4a7a..d9f60ec279 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -202,11 +202,9 @@ eth_dev_vmbus_release(struct rte_eth_dev *eth_dev)
static int hn_set_parameter(const char *key, const char *value, void *opaque)
{
struct hn_data *hv = opaque;
- char *endp = NULL;
- unsigned long v;
+ uint64_t v;
- v = strtoul(value, &endp, 0);
- if (*value == '\0' || *endp != '\0') {
+ if (rte_kvargs_to_uint(value, 0, UINT32_MAX, &v) < 0) {
PMD_DRV_LOG(ERR, "invalid parameter %s=%s", key, value);
return -EINVAL;
}--
2.53.0