From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 354804F94 for ; Tue, 30 Oct 2018 15:23:01 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 07:23:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,444,1534834800"; d="scan'208";a="82092130" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by fmsmga007.fm.intel.com with ESMTP; 30 Oct 2018 07:22:59 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan , cristian.dumitrescu@intel.com, jasvinder.singh@intel.com Date: Tue, 30 Oct 2018 14:22:52 +0000 Message-Id: <1540909372-23110-4-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1540909372-23110-1-git-send-email-reshma.pattan@intel.com> References: <1540909372-23110-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH 4/4] net/softnic: fix string copy 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: , X-List-Received-Date: Tue, 30 Oct 2018 14:23:01 -0000 From: Reshma Pattan Use strlcpy instead of strcpy to avoid buffer overrun. Coverity issue: 323478 Fixes: b767f8efc8 ("net/softnic: replace pointers with arrays") CC: cristian.dumitrescu@intel.com CC: jasvinder.singh@intel.com Signed-off-by: Reshma Pattan --- drivers/net/softnic/rte_eth_softnic_cli.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/softnic/rte_eth_softnic_cli.c b/drivers/net/softnic/rte_eth_softnic_cli.c index a0beca904..57b623377 100644 --- a/drivers/net/softnic/rte_eth_softnic_cli.c +++ b/drivers/net/softnic/rte_eth_softnic_cli.c @@ -1867,7 +1867,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_RXQ; - strcpy(p.dev_name, tokens[t0 + 1]); + strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name)); if (strcmp(tokens[t0 + 2], "rxq") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, "rxq"); @@ -1890,7 +1890,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_SWQ; - strcpy(p.dev_name, tokens[t0 + 1]); + strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name)); t0 += 2; } else if (strcmp(tokens[t0], "tmgr") == 0) { @@ -1902,7 +1902,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TMGR; - strcpy(p.dev_name, tokens[t0 + 1]); + strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name)); t0 += 2; } else if (strcmp(tokens[t0], "tap") == 0) { @@ -1914,7 +1914,7 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, p.type = PORT_IN_TAP; - strcpy(p.dev_name, tokens[t0 + 1]); + strlcpy(p.dev_name, tokens[t0 + 1], sizeof(p.dev_name)); if (strcmp(tokens[t0 + 2], "mempool") != 0) { snprintf(out, out_size, MSG_ARG_NOT_FOUND, @@ -2009,7 +2009,8 @@ cmd_pipeline_port_in(struct pmd_internals *softnic, return; } - strcpy(p.action_profile_name, tokens[t0 + 1]); + strlcpy(p.action_profile_name, tokens[t0 + 1], + sizeof(p.action_profile_name)); t0 += 2; } -- 2.17.1