DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sean Morrissey <sean.morrissey@intel.com>
To: Ori Kam <orika@nvidia.com>, Xiaoyun Li <xiaoyun.li@intel.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>
Cc: dev@dpdk.org, Sean Morrissey <sean.morrissey@intel.com>,
	stable@dpdk.org, wei.zhao1@intel.com,
	Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [PATCH v2] app/testpmd: fix dereference before null check
Date: Tue, 18 Jan 2022 10:53:09 +0000	[thread overview]
Message-ID: <20220118105309.1362804-1-sean.morrissey@intel.com> (raw)
In-Reply-To: <20211209162727.12295-1-sean.morrissey@intel.com>

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@dpdk.org
Cc: wei.zhao1@intel.com

Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@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


  parent reply	other threads:[~2022-01-18 10:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 16:27 [PATCH v1] " Sean Morrissey
2022-01-18  9:59 ` Ferruh Yigit
2022-01-18 10:53 ` Sean Morrissey [this message]
2022-01-18 13:28   ` [PATCH v2] " Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220118105309.1362804-1-sean.morrissey@intel.com \
    --to=sean.morrissey@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=orika@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=wei.zhao1@intel.com \
    --cc=xiaoyun.li@intel.com \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).