DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] hash: fix sprintf with snprintf
@ 2019-02-14 12:57 Pallantla Poornima
       [not found] ` <EE76425279735140910E0DBA3963DA361BBA864D@BGSMSX103.gar.corp.intel.com>
  2019-03-26 10:27 ` [dpdk-dev] [PATCH v3] app/test/hash: " Pallantla Poornima
  0 siblings, 2 replies; 7+ messages in thread
From: Pallantla Poornima @ 2019-02-14 12:57 UTC (permalink / raw)
  To: dev
  Cc: reshma.pattan, yipeng1.wang, sameh.gobriel, bruce.richardson,
	pablo.de.lara.guarch, stephen, Pallantla Poornima, stable

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 <pallantlax.poornima@intel.com>
---
v2: Addressed review comment to correct the format specifier of 
hastest_key_lens.
---

 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..5648fce02 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%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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-04 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 12:57 [dpdk-dev] [PATCH v2] hash: fix sprintf with snprintf Pallantla Poornima
     [not found] ` <EE76425279735140910E0DBA3963DA361BBA864D@BGSMSX103.gar.corp.intel.com>
2019-03-25 18:05   ` Wang, Yipeng1
2019-03-25 18:05     ` Wang, Yipeng1
2019-03-26 10:27 ` [dpdk-dev] [PATCH v3] app/test/hash: " Pallantla Poornima
2019-03-26 10:27   ` Pallantla Poornima
2019-04-04 23:59   ` Thomas Monjalon
2019-04-04 23:59     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).