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 294C8C354 for ; Wed, 22 Jun 2016 11:24:38 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 22 Jun 2016 02:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,509,1459839600"; d="scan'208";a="1002897446" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by orsmga002.jf.intel.com with ESMTP; 22 Jun 2016 02:24:36 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.193]) by IRSMSX153.ger.corp.intel.com ([169.254.9.105]) with mapi id 14.03.0248.002; Wed, 22 Jun 2016 10:24:35 +0100 From: "Pattan, Reshma" To: "Richardson, Bruce" , Anupam Kapoor CC: "Yigit, Ferruh" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 3/3] app/pdump: fix string overflow Thread-Index: AQHRy9Ai0jYFkYexPkKplJ9D/ugi/5/0GjqAgADg+4CAACtSAIAAEVjQ Date: Wed, 22 Jun 2016 09:24:34 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831F01050C4A@IRSMSX109.ger.corp.intel.com> References: <1466522285-15023-1-git-send-email-reshma.pattan@intel.com> <1466522285-15023-4-git-send-email-reshma.pattan@intel.com> <57697789.6050500@intel.com> <20160622092130.GB9728@bricha3-MOBL3> In-Reply-To: <20160622092130.GB9728@bricha3-MOBL3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWM5ODk0MzAtYjZjMS00YTdiLTljMGEtNGI0NTA3MGY3YWQzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImxySll4ODZHXC9ZbTBrVnJIZm1IamlyWGYyTUtxVFdUTEpZR1lBYXQyRVlRPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: Wed, 22 Jun 2016 09:24:38 -0000 Hi, > -----Original Message----- > From: Richardson, Bruce > Sent: Wednesday, June 22, 2016 10:22 AM > To: Anupam Kapoor > Cc: Yigit, Ferruh ; Pattan, Reshma > ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 3/3] app/pdump: fix string overflow >=20 > On Wed, Jun 22, 2016 at 12:16:27PM +0530, Anupam Kapoor wrote: > > > 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? > > > > why not just use a snprintf(...) here since it has better error behavio= r ? > > although compared to str*cpy it might be a bit slow, but hopefully > > that should be ok ? > > >=20 > Definite +1. For safely copying strings I think snprintf is often the eas= iest API to > use. >=20 Ok, will make the changes. Thanks, Reshma