From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 548553772; Tue, 12 Mar 2019 08:41:20 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 00:41:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,470,1544515200"; d="scan'208";a="154202782" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by fmsmga001.fm.intel.com with ESMTP; 12 Mar 2019 00:41:18 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.152]) by IRSMSX106.ger.corp.intel.com ([169.254.8.205]) with mapi id 14.03.0415.000; Tue, 12 Mar 2019 07:41:17 +0000 From: "Parthasarathy, JananeeX M" To: 'Aaron Conole' CC: "'dev@dpdk.org'" , "Pattan, Reshma" , "Rao, Nikhil" , "'stable@dpdk.org'" , "Poornima, PallantlaX" Thread-Topic: [dpdk-dev] [PATCH] test/eventdev: fix sprintf with snprintf Thread-Index: AQHUvgj2T17TkvJBCk+La8jLJLLRdKXWbCfagBC9+gCAIKa3cA== Date: Tue, 12 Mar 2019 07:41:17 +0000 Message-ID: <7AE31235A30B41498D1C31348DC858BD5B54DCD4@IRSMSX103.ger.corp.intel.com> References: <1549449822-412-1-git-send-email-pallantlax.poornima@intel.com> <7AE31235A30B41498D1C31348DC858BD5B534A73@IRSMSX103.ger.corp.intel.com> In-Reply-To: <7AE31235A30B41498D1C31348DC858BD5B534A73@IRSMSX103.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] test/eventdev: fix sprintf with snprintf X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Mar 2019 07:41:21 -0000 Hi >-----Original Message----- >From: Parthasarathy, JananeeX M >Sent: Tuesday, February 19, 2019 6:33 PM >To: Aaron Conole ; Poornima, PallantlaX > >Cc: dev@dpdk.org; Pattan, Reshma ; Rao, Nikhil >; stable@dpdk.org >Subject: RE: [dpdk-dev] [PATCH] test/eventdev: fix sprintf with snprintf > > > >>-----Original Message----- >>From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Aaron Conole >>Sent: Saturday, February 09, 2019 2:50 AM >>To: Poornima, PallantlaX >>Cc: dev@dpdk.org; Pattan, Reshma ; Rao, Nikhil >>; stable@dpdk.org >>Subject: Re: [dpdk-dev] [PATCH] test/eventdev: fix sprintf with >>snprintf >> >>Pallantla Poornima writes: >> >>> sprintf function is not secure as it doesn't check the length of string= . >>> More secure function snprintf is used. >>> >>> Fixes: 2a9c83ae3b ("test/eventdev: add multi-ports test") >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Pallantla Poornima >>> --- >>> test/test/test_event_eth_rx_adapter.c | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/test/test/test_event_eth_rx_adapter.c >>> b/test/test/test_event_eth_rx_adapter.c >>> index 1d3be82b5..38f5c039f 100644 >>> --- a/test/test/test_event_eth_rx_adapter.c >>> +++ b/test/test/test_event_eth_rx_adapter.c >>> @@ -479,7 +479,8 @@ adapter_multi_eth_add_del(void) >>> /* add the max port for rx_adapter */ >>> port_index =3D rte_eth_dev_count_total(); >>> for (; port_index < RTE_MAX_ETHPORTS; port_index +=3D 1) { >>> - sprintf(driver_name, "%s%u", "net_null", drv_id); >>> + snprintf(driver_name, sizeof(driver_name), "%s%u", "net_null", >>> + drv_id); >>> err =3D rte_vdev_init(driver_name, NULL); >>> TEST_ASSERT(err =3D=3D 0, "Failed driver %s got %d", >>> driver_name, err); >> >>You call this a fix, but it's not possible for the value of drv_id to >>exceed '32' and the buffer size is plenty accommodating for that. Did >>I miss something? What is this fixing? > >It is better practice to use snprintf although in this case buffer will no= t overflow >as size is big enough to accommodate. The changes were done mainly to >replace sprintf to snprintf. Probably we can remove "fix" line as it is no= t issue in >this scenario. > >Thanks >M.P.Jananee Please suggest if we can remove "fix" line. Thanks