From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2E111C408 for ; Tue, 21 Jun 2016 19:21:16 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 21 Jun 2016 10:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,505,1459839600"; d="scan'208";a="992293946" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.90]) ([10.237.220.90]) by fmsmga001.fm.intel.com with ESMTP; 21 Jun 2016 10:21:14 -0700 To: Reshma Pattan , dev@dpdk.org References: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> <1466522285-15023-4-git-send-email-reshma.pattan@intel.com> From: Ferruh Yigit Message-ID: <57697789.6050500@intel.com> Date: Tue, 21 Jun 2016 18:21:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1466522285-15023-4-git-send-email-reshma.pattan@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [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 17:21:16 -0000 On 6/21/2016 4:18 PM, Reshma Pattan wrote: > 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); I guess size-1 is to give room for terminating null byte, but for this case is it guarantied that pt->rx_dev last byte is NULL?