From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3FE47C316 for ; Tue, 21 Jun 2016 19:14:12 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 21 Jun 2016 10:14:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,505,1459839600"; d="scan'208";a="992288776" 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:14:10 -0700 To: Reshma Pattan , dev@dpdk.org References: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> <1466522285-15023-3-git-send-email-reshma.pattan@intel.com> From: Ferruh Yigit Message-ID: <576975E1.9030704@intel.com> Date: Tue, 21 Jun 2016 18:14:09 +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-3-git-send-email-reshma.pattan@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 2/3] 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:14:12 -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. > > Cverity issue 127350: string overflow > > Fixes: 278f945402c5 ("pdump: add new library for packet capture") > > Signed-off-by: Reshma Pattan > --- > lib/librte_pdump/rte_pdump.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c > index dbc6816..05513d6 100644 > --- a/lib/librte_pdump/rte_pdump.c > +++ b/lib/librte_pdump/rte_pdump.c > @@ -460,8 +460,7 @@ pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type) > SOCKET_PATH_HOME, __func__, __LINE__); > return -1; > } > - } > - else > + } else syntax fix may be not belong to this patch > dir = SOCKET_PATH_VAR_RUN; > } > > @@ -800,13 +799,15 @@ pdump_prepare_client_request(char *device, uint16_t queue, > req.flags = flags; > req.op = operation; > if ((operation & ENABLE) != 0) { > - strncpy(req.data.en_v1.device, device, strlen(device)); > + strncpy(req.data.en_v1.device, device, > + sizeof(req.data.en_v1.device)-1); "-" missing spaces around