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 A68BD10A3; Tue, 26 Mar 2019 11:28:17 +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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2019 03:28:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,271,1549958400"; d="scan'208";a="155261929" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 26 Mar 2019 03:28:15 -0700 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 x2QASE78023248; Tue, 26 Mar 2019 10:28:14 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x2QARXgW021762; Tue, 26 Mar 2019 10:27:33 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with œ id x2QARXFk021755; Tue, 26 Mar 2019 10:27:33 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: Tue, 26 Mar 2019 10:27:23 +0000 Message-Id: <1553596043-21363-1-git-send-email-pallantlax.poornima@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> References: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> Subject: [dpdk-dev] [PATCH v3] app/test/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: , X-List-Received-Date: Tue, 26 Mar 2019 10:28:18 -0000 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 Acked-by: Yipeng Wang --- v3: Rebased. v2: Addressed review comment to correct the format specifier of hastest_key_lens. --- app/test/test_hash_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index 525211180..5648fce02 100644 --- a/app/test/test_hash_perf.c +++ b/app/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%u_data", + hashtest_key_lens[table_index]); else - sprintf(name, "test_hash%d", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%u", + hashtest_key_lens[table_index]); if (with_locks) -- 2.17.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4A29EA05D3 for ; Tue, 26 Mar 2019 11:28:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04D892BFA; Tue, 26 Mar 2019 11:28:20 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A68BD10A3; Tue, 26 Mar 2019 11:28:17 +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 fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2019 03:28:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,271,1549958400"; d="scan'208";a="155261929" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 26 Mar 2019 03:28:15 -0700 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 x2QASE78023248; Tue, 26 Mar 2019 10:28:14 GMT Received: from wgcvswdev001.ir.intel.com (localhost [127.0.0.1]) by wgcvswdev001.ir.intel.com with ESMTP id x2QARXgW021762; Tue, 26 Mar 2019 10:27:33 GMT Received: (from ppoornix@localhost) by wgcvswdev001.ir.intel.com with œ id x2QARXFk021755; Tue, 26 Mar 2019 10:27:33 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: Tue, 26 Mar 2019 10:27:23 +0000 Message-Id: <1553596043-21363-1-git-send-email-pallantlax.poornima@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> References: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> Subject: [dpdk-dev] [PATCH v3] app/test/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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190326102723.s-6imEksbrhLC2QUEX-CLFhFuvDlVWtQT7X7MFpHUaI@z> 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 Acked-by: Yipeng Wang --- v3: Rebased. v2: Addressed review comment to correct the format specifier of hastest_key_lens. --- app/test/test_hash_perf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/test/test_hash_perf.c b/app/test/test_hash_perf.c index 525211180..5648fce02 100644 --- a/app/test/test_hash_perf.c +++ b/app/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%u_data", + hashtest_key_lens[table_index]); else - sprintf(name, "test_hash%d", hashtest_key_lens[table_index]); + snprintf(name, sizeof(name), "test_hash%u", + hashtest_key_lens[table_index]); if (with_locks) -- 2.17.2