From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pallantla Poornima Subject: [PATCH v3] app/test/hash: fix sprintf with snprintf Date: Tue, 26 Mar 2019 10:27:23 +0000 Message-ID: <1553596043-21363-1-git-send-email-pallantlax.poornima@intel.com> References: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> 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 To: dev@dpdk.org Return-path: In-Reply-To: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com> 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 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