From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3E9CF8E72 for ; Fri, 11 Dec 2015 17:16:49 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 11 Dec 2015 08:16:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,414,1444719600"; d="scan'208";a="869647658" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga002.jf.intel.com with ESMTP; 11 Dec 2015 08:16:47 -0800 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.13]) by IRSMSX102.ger.corp.intel.com ([169.254.2.251]) with mapi id 14.03.0248.002; Fri, 11 Dec 2015 16:16:46 +0000 From: "Richardson, Bruce" To: "Mcnamara, John" , "Zhang, Roy Fan" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed size buffer defect Thread-Index: AQHRNAdDZVUxhy6HuEG3YAe+jWd7vp7F64aAgAAK93A= Date: Fri, 11 Dec 2015 16:16:45 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B035991156@IRSMSX103.ger.corp.intel.com> References: <1449833351-10011-1-git-send-email-roy.fan.zhang@intel.com> <1449833351-10011-2-git-send-email-roy.fan.zhang@intel.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-inteldataclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsIiwiaWQiOiI2ZjY5NDU4MS04MTJkLTQwNmEtYWViNi04Mzk5NjY5NzRkYzIiLCJwcm9wcyI6W3sibiI6IkludGVsRGF0YUNsYXNzaWZpY2F0aW9uIiwidmFscyI6W3sidmFsdWUiOiJDVFBfSUMifV19XX0sIlN1YmplY3RMYWJlbHMiOltdLCJUTUNWZXJzaW9uIjoiMTUuNC4xMC4xOSIsIlRydXN0ZWRMYWJlbEhhc2giOiIzeHBTXC93NXppWjhkbU4zYVlRbVdmSk9DdkRRWVp6dEZwXC9aQm1PXC9DSllrPSJ9 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] example/ip_pipeline: fix copy into fixed size buffer defect 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: Fri, 11 Dec 2015 16:16:49 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Mcnamara, John > Sent: Friday, December 11, 2015 3:37 PM > To: Zhang, Roy Fan ; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed > size buffer defect >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Fan Zhang > > Sent: Friday, December 11, 2015 11:29 AM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH] example/ip_pipeline: fix copy into fixed > > size buffer defect > > > > Coverity issue: 107133 > > Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization > > parameters") > > > > Signed-off-by: Fan Zhang > > Acked-by: Cristian Dumitrescu > > --- > > examples/ip_pipeline/init.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c > > index bc6d6d9..5bcb420 100644 > > --- a/examples/ip_pipeline/init.c > > +++ b/examples/ip_pipeline/init.c > > @@ -1068,7 +1068,10 @@ static void app_pipeline_params_get(struct > > app_params *app, > > uint32_t i; > > uint32_t mempool_id; > > > > - strcpy(p_out->name, p_in->name); > > + if (sizeof(p_in->name) > PIPELINE_NAME_SIZE) > > + strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE); > > + else > > + strcpy(p_out->name, p_in->name); > > > > p_out->socket_id =3D (int) p_in->socket_id; > > >=20 > Hi Fan, >=20 > I think there could still be issues here (depending of the size/types of > p_out->name and p_in->name). Probably better as something like: >=20 > strncpy(p_out->name, p_in->name, PIPELINE_NAME_SIZE); > p_out->name[PIPELINE_NAME_SIZE -1] =3D '\0'; >=20 > John. > -- Use snprintf to avoid having to explicitly null terminate, perhaps? /Bruce