[PATCH v2] app/testpmd: fix dereference before null check
Sean Morrissey
sean.morrissey at intel.com
Tue Jan 18 11:53:09 CET 2022
Assign 'left' variable only after null check on 'size'
as function returns if 'size' is null.
Coverity issue: 374381
Fixes: 169a9fed1f4 ("app/testpmd: fix hex string parser support for flow API")
Cc: stable at dpdk.org
Cc: wei.zhao1 at intel.com
Signed-off-by: Sean Morrissey <sean.morrissey at intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit at intel.com>
---
app/test-pmd/cmdline_flow.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 5c2bba48ad..bbaf18d76e 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -7702,8 +7702,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) ||
@@ -7712,6 +7712,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;
--
2.25.1
More information about the dev
mailing list