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 f924a8d3bb838bffbaf2c2d47bada952e45b475f ]

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 cpaelzer committed Feb 25, 2022
1 parent f4a9c37 commit a6dd7ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/test-pmd/cmdline_flow.c
Expand Up @@ -5293,8 +5293,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 @@ -5303,6 +5303,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 a6dd7ff

Please sign in to comment.