From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA14FA0524; Fri, 6 Nov 2020 04:32:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0C1C2C1A; Fri, 6 Nov 2020 04:32:05 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 789522BF5 for ; Fri, 6 Nov 2020 04:32:04 +0100 (CET) IronPort-SDR: B/SwPV1EB8+IiQQm+UoPqW1ZltsdtO5QqZZH3Ble2CsGL8L3++8X98Q3wnWsOvMm6k5yLtbPuG 8+Ko3RvqIDCA== X-IronPort-AV: E=McAfee;i="6000,8403,9796"; a="157276083" X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="157276083" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2020 19:32:02 -0800 IronPort-SDR: dO7f981MN13pUxyP7FY66DfllDIM1HOq2klS7c5OowNNWftLcvITDeIr3eYNGu5vPlmdZCHbUy uE6rDnclSW2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,454,1596524400"; d="scan'208";a="321452020" Received: from dpdk_jiangcheng.sh.intel.com ([10.67.119.112]) by orsmga003.jf.intel.com with ESMTP; 05 Nov 2020 19:32:00 -0800 From: Cheng Jiang To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, patrick.fu@intel.com, YvonneX.Yang@intel.com, Cheng Jiang Date: Fri, 6 Nov 2020 03:24:01 +0000 Message-Id: <20201106032401.9149-1-Cheng1.jiang@intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] examples/vhost: fix missing args length check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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