From patchwork Wed Feb 6 10:52:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Poornima, PallantlaX" X-Patchwork-Id: 50142 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 888AA1B3BA; Wed, 6 Feb 2019 11:53:01 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id E9AE21B3AD; Wed, 6 Feb 2019 11:52:59 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2019 02:52:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,339,1544515200"; d="scan'208";a="131491773" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 06 Feb 2019 02:52:57 -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 x16Aquvg008568; Wed, 6 Feb 2019 10:52:56 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x16AqL4L003082; Wed, 6 Feb 2019 10:52:21 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with ? id x16AqLNB003077; Wed, 6 Feb 2019 10:52:21 GMT From: Pallantla Poornima To: dev@dpdk.org Cc: reshma.pattan@intel.com, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com, Pallantla Poornima , stable@dpdk.org Date: Wed, 6 Feb 2019 10:52:17 +0000 Message-Id: <1549450337-2890-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] hash: 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" sprintf function is not secure as it doesn't check the length of string. More secure function snprintf is used. Fixes: 473d1bebce ("hash: allow to store data in hash table") Cc: stable@dpdk.org Signed-off-by: Pallantla Poornima --- test/test/test_hash_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test/test_hash_perf.c b/test/test/test_hash_perf.c index 525211180..c09b10f2e 100644 --- a/test/test/test_hash_perf.c +++ b/test/test/test_hash_perf.c @@ -85,9 +85,11 @@ create_table(unsigned int with_data, unsigned int table_index, if (with_data) /* Table will store 8-byte data */ - sprintf(name, "test_hash%d_data", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%d_data", + hashtest_key_lens[table_index]); else - sprintf(name, "test_hash%d", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%d", + hashtest_key_lens[table_index]); if (with_locks)