DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cheng Jiang <Cheng1.jiang@intel.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, patrick.fu@intel.com, YvonneX.Yang@intel.com,
	Cheng Jiang <Cheng1.jiang@intel.com>
Subject: [dpdk-dev] [PATCH v1] examples/vhost: fix missing args length check
Date: Fri,  6 Nov 2020 03:24:01 +0000	[thread overview]
Message-ID: <20201106032401.9149-1-Cheng1.jiang@intel.com> (raw)

Add args length check before copying to fix the coverity issue.

Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
Coverity issue: 363741

Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
 examples/vhost/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 59a1aff07c..ec88874d16 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -634,6 +634,12 @@ us_vhost_parse_args(int argc, char **argv)
 
 			if (!strncmp(long_option[option_index].name,
 						"dma-type", MAX_LONG_OPT_SZ)) {
+				if (strlen(optarg) >= MAX_LONG_OPT_SZ) {
+					RTE_LOG(INFO, VHOST_CONFIG,
+						"Wrong DMA type\n");
+					us_vhost_usage(prgname);
+					return -1;
+				}
 				strcpy(dma_type, optarg);
 			}
 
-- 
2.29.2


             reply	other threads:[~2020-11-06  3:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  3:24 Cheng Jiang [this message]
2020-11-10  9:44 ` Maxime Coquelin
2020-11-13  8:41 ` Maxime Coquelin

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=20201106032401.9149-1-Cheng1.jiang@intel.com \
    --to=cheng1.jiang@intel.com \
    --cc=YvonneX.Yang@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=patrick.fu@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).