From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 31244C40A for ; Tue, 21 Jun 2016 17:19:19 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 21 Jun 2016 08:18:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,504,1459839600"; d="scan'208";a="722880396" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jun 2016 08:18:09 -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 u5LFI7VH024669; Tue, 21 Jun 2016 16:18:08 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u5LFI7Fg015085; Tue, 21 Jun 2016 16:18:07 +0100 Received: (from reshmapa@localhost) by sivswdev02.ir.intel.com with id u5LFI7PT015080; Tue, 21 Jun 2016 16:18:07 +0100 From: Reshma Pattan To: dev@dpdk.org Cc: Reshma Pattan Date: Tue, 21 Jun 2016 16:18:05 +0100 Message-Id: <1466522285-15023-4-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> References: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH 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: Tue, 21 Jun 2016 15:19:19 -0000 using source length in strncpy can cause destination overflow if destination length is not big enough to handle the source string. Changes are made to use destination size instead of source length in strncpy. 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..af92ef3 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)); + strncpy(pt->rx_dev, value, sizeof(pt->rx_dev)-1); /* 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)); + strncpy(pt->tx_dev, value, sizeof(pt->tx_dev)-1); /* identify the tx stream type for pcap vdev */ if (if_nametoindex(pt->tx_dev)) pt->tx_vdev_stream_type = IFACE; -- 2.5.0