From: Cheng Jiang <Cheng1.jiang@intel.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, david.marchand@redhat.com,
Cheng Jiang <Cheng1.jiang@intel.com>
Subject: [dpdk-dev] [PATCH v2] examples/vhost: fix potential overflow in args process
Date: Tue, 27 Apr 2021 03:14:01 +0000 [thread overview]
Message-ID: <20210427031401.4369-1-Cheng1.jiang@intel.com> (raw)
In-Reply-To: <20210419054426.26812-1-Cheng1.jiang@intel.com>
Change the way passing args to fix potential overflow in args process.
Coverity issue: 363741
Fixes: 965b06f0358 ("examples/vhost: enhance getopt_long usage")
Signed-off-by: Cheng Jiang <Cheng1.jiang@intel.com>
---
v2:
* Change the way passing args
* Change git log
examples/vhost/main.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 119ba7e01..3e2e9a45c 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -55,9 +55,6 @@
#define INVALID_PORT_ID 0xFF
-/* Maximum long option length for option parsing. */
-#define MAX_LONG_OPT_SZ 64
-
/* mask of enabled ports */
static uint32_t enabled_port_mask = 0;
@@ -97,7 +94,7 @@ static int builtin_net_driver;
static int async_vhost_driver;
-static char dma_type[MAX_LONG_OPT_SZ];
+static char *dma_type;
/* Specify timeout (in useconds) between retries on RX. */
static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US;
@@ -201,7 +198,7 @@ struct vhost_bufftable *vhost_txbuff[RTE_MAX_LCORE * MAX_VHOST_DEVICE];
static inline int
open_dma(const char *value)
{
- if (strncmp(dma_type, "ioat", 4) == 0)
+ if (dma_type != NULL && strncmp(dma_type, "ioat", 4) == 0)
return open_ioat(value);
return -1;
@@ -669,7 +666,7 @@ us_vhost_parse_args(int argc, char **argv)
break;
case OPT_DMA_TYPE_NUM:
- strcpy(dma_type, optarg);
+ dma_type = optarg;
break;
case OPT_DMAS_NUM:
@@ -1472,7 +1469,7 @@ new_device(int vid)
struct rte_vhost_async_features f;
struct rte_vhost_async_channel_ops channel_ops;
- if (strncmp(dma_type, "ioat", 4) == 0) {
+ if (dma_type != NULL && strncmp(dma_type, "ioat", 4) == 0) {
channel_ops.transfer_data = ioat_transfer_data_cb;
channel_ops.check_completed_copies =
ioat_check_completed_copies_cb;
--
2.29.2
next prev parent reply other threads:[~2021-04-27 3:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 5:44 [dpdk-dev] [PATCH] " Cheng Jiang
2021-04-26 8:24 ` [dpdk-dev] [dpdk-stable] " David Marchand
2021-04-27 3:17 ` Jiang, Cheng1
2021-04-27 3:14 ` Cheng Jiang [this message]
2021-05-03 14:01 ` [dpdk-dev] [PATCH v2] " Maxime Coquelin
2021-05-04 8:28 ` 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=20210427031401.4369-1-Cheng1.jiang@intel.com \
--to=cheng1.jiang@intel.com \
--cc=chenbo.xia@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.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).