From patchwork Thu Feb 14 09:45:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poornima, PallantlaX" X-Patchwork-Id: 50313 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 130151B1F2; Thu, 14 Feb 2019 10:46:34 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 051F61B1E6; Thu, 14 Feb 2019 10:46:31 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2019 01:46:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,368,1544515200"; d="scan'208";a="143382378" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 14 Feb 2019 01:46:29 -0800 Received: from wgcvswdev001.ir.intel.com (wgcvswdev001.ir.intel.com [10.102.246.100]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x1E9kTof026145; Thu, 14 Feb 2019 09:46:29 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x1E9jriB005351; Thu, 14 Feb 2019 09:45:53 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with ? id x1E9jq8c005346; Thu, 14 Feb 2019 09:45:52 GMT From: Pallantla Poornima To: dev@dpdk.org Cc: reshma.pattan@intel.com, david.hunt@intel.com, bruce.richardson@intel.com, ferruh.yigit@intel.com, Pallantla Poornima , stable@dpdk.org Date: Thu, 14 Feb 2019 09:45:49 +0000 Message-Id: <1550137549-5184-1-git-send-email-pallantlax.poornima@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2] test/distributor: fix sprintf with strlcpy 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" sprintf function is not secure as it doesn't check the length of string. replaced sprintf with strlcpy. Fixes: f74df2c57e ("test/distributor: test single and burst API") Cc: stable@dpdk.org Signed-off-by: Pallantla Poornima Acked-by: David Hunt --- v2: Addressed review comment to replace snprintf to strlcpy. --- test/test/test_distributor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c index 98919ec0c..da3348fd1 100644 --- a/test/test/test_distributor.c +++ b/test/test/test_distributor.c @@ -11,6 +11,7 @@ #include #include #include +#include #define ITER_POWER 20 /* log 2 of how many iterations we do when timing. */ #define BURST 32 @@ -642,9 +643,11 @@ test_distributor(void) worker_params.dist = dist[i]; if (i) - sprintf(worker_params.name, "burst"); + strlcpy(worker_params.name, "burst", + sizeof(worker_params.name)); else - sprintf(worker_params.name, "single"); + strlcpy(worker_params.name, "single", + sizeof(worker_params.name)); rte_eal_mp_remote_launch(handle_work, &worker_params, SKIP_MASTER);