From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C78895F13; Wed, 6 Feb 2019 11:48:21 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2019 02:48:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,339,1544515200"; d="scan'208";a="136302838" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.54]) by orsmga001.jf.intel.com with SMTP; 06 Feb 2019 02:48:18 -0800 Received: by (sSMTP sendmail emulation); Wed, 06 Feb 2019 10:48:17 +0000 Date: Wed, 6 Feb 2019 10:48:16 +0000 From: Bruce Richardson To: Pallantla Poornima Cc: dev@dpdk.org, reshma.pattan@intel.com, david.hunt@intel.com, stable@dpdk.org Message-ID: <20190206104816.GA79664@bricha3-MOBL.ger.corp.intel.com> References: <1549449547-32343-1-git-send-email-pallantlax.poornima@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1549449547-32343-1-git-send-email-pallantlax.poornima@intel.com> User-Agent: Mutt/1.11.2 (2019-01-07) Subject: Re: [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2019 10:48:22 -0000 On Wed, Feb 06, 2019 at 10:39:07AM +0000, Pallantla Poornima wrote: > sprintf function is not secure as it doesn't check the length of string. > More secure function snprintf is used. > > Fixes: f74df2c57e ("test/distributor: test single and burst API") > Cc: stable@dpdk.org > > Signed-off-by: Pallantla Poornima > --- > test/test/test_distributor.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c > index 98919ec0c..03df32b05 100644 > --- a/test/test/test_distributor.c > +++ b/test/test/test_distributor.c > @@ -642,9 +642,11 @@ test_distributor(void) > > worker_params.dist = dist[i]; > if (i) > - sprintf(worker_params.name, "burst"); > + snprintf(worker_params.name, > + sizeof(worker_params.name), "burst"); > else > - sprintf(worker_params.name, "single"); > + snprintf(worker_params.name, > + sizeof(worker_params.name), "single"); > > rte_eal_mp_remote_launch(handle_work, > &worker_params, SKIP_MASTER); > -- While not wrong here, I think changing these to string copies using "strlcpy" might be better, since this is constant text in each case, and no printf formatting is actually needed. /Bruce