Skip to content

Commit

Permalink
event/octeontx: fix possible integer overflow
Browse files Browse the repository at this point in the history
The last argument passed to ssovf_parsekv() is an
unsigned char*, but it is accessed as an integer.
This can lead to an integer overflow.

Hence, make ensure the argument is accessed as a char
and for better error handling use strtol instead of atoi.

Bugzilla ID: 1512
Fixes: 3516327 ("event/octeontx: add selftest to device arguments")
Cc: stable@dpdk.org

Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>
Tested-by: Ali Alnubani <alialnu@nvidia.com>
  • Loading branch information
hpothula-git authored and jerinjacobk committed Oct 28, 2024
1 parent c91717f commit 30776b2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/event/octeontx/ssovf_evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,20 @@ ssovf_close(struct rte_eventdev *dev)
}

static int
ssovf_parsekv(const char *key __rte_unused, const char *value, void *opaque)
ssovf_parsekv(const char *key, const char *value, void *opaque)
{
int *flag = opaque;
*flag = !!atoi(value);
uint8_t *flag = opaque;
uint64_t v;
char *end;

errno = 0;
v = strtoul(value, &end, 0);
if ((errno != 0) || (value == end) || *end != '\0' || v > 1) {
ssovf_log_err("invalid %s value %s", key, value);
return -EINVAL;
}

*flag = !!v;
return 0;
}

Expand Down

0 comments on commit 30776b2

Please sign in to comment.