Skip to content

Commit

Permalink
app/testpmd: fix dereference before null check
Browse files Browse the repository at this point in the history
[ upstream commit f924a8d ]

Assign 'left' variable only after null check on 'size'
as function returns if 'size' is null.

Coverity issue: 374381
Fixes: 169a9fe ("app/testpmd: fix hex string parser support for flow API")

Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
Sean Morrissey authored and bluca committed Feb 14, 2022
1 parent 239f57b commit a2f86fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/test-pmd/cmdline_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -6411,8 +6411,8 @@ parse_string(struct context *ctx, const struct token *token,
static int
parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
{
uint32_t left = *size;
const uint8_t *head = dst;
uint32_t left;

/* Check input parameters */
if ((src == NULL) ||
Expand All @@ -6421,6 +6421,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
(*size == 0))
return -1;

left = *size;

/* Convert chars to bytes */
while (left) {
char tmp[3], *end = tmp;
Expand Down

0 comments on commit a2f86fa

Please sign in to comment.