From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 27C028E6E for ; Wed, 22 Jun 2016 16:10:48 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 22 Jun 2016 07:08:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,509,1459839600"; d="scan'208";a="992912990" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 22 Jun 2016 07:07:59 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u5ME7w01004998; Wed, 22 Jun 2016 15:07:58 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u5ME7w3e011928; Wed, 22 Jun 2016 15:07:58 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u5ME7vIT011924; Wed, 22 Jun 2016 15:07:58 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Wed, 22 Jun 2016 15:07:55 +0100 Message-Id: <1466604475-11864-4-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466604475-11864-1-git-send-email-reshma.pattan@intel.com> References: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> <1466604475-11864-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH v2 3/3] app/pdump: fix string overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2016 14:10:48 -0000 replaced strncpy with snprintf for safely copying the strings. Coverity issue 127351: string overflow Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing") Signed-off-by: Reshma Pattan --- app/pdump/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index f8923b9..fe4d38a 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -217,12 +217,12 @@ parse_rxtxdev(const char *key, const char *value, void *extra_args) struct pdump_tuples *pt = extra_args; if (!strcmp(key, PDUMP_RX_DEV_ARG)) { - strncpy(pt->rx_dev, value, strlen(value)); + snprintf(pt->rx_dev, sizeof(pt->rx_dev), "%s", value); /* identify the tx stream type for pcap vdev */ if (if_nametoindex(pt->rx_dev)) pt->rx_vdev_stream_type = IFACE; } else if (!strcmp(key, PDUMP_TX_DEV_ARG)) { - strncpy(pt->tx_dev, value, strlen(value)); + snprintf(pt->tx_dev, sizeof(pt->tx_dev), "%s", value); /* identify the tx stream type for pcap vdev */ if (if_nametoindex(pt->tx_dev)) pt->tx_vdev_stream_type = IFACE; -- 2.5.0