* [dpdk-dev] [PATCH] hash: fix sprintf with snprintf
@ 2019-02-06 10:52 Pallantla Poornima
2019-02-06 16:18 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Pallantla Poornima @ 2019-02-06 10:52 UTC (permalink / raw)
To: dev
Cc: reshma.pattan, yipeng1.wang, sameh.gobriel, bruce.richardson,
pablo.de.lara.guarch, 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>
---
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)
--
2.17.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] hash: fix sprintf with snprintf
2019-02-06 10:52 [dpdk-dev] [PATCH] hash: fix sprintf with snprintf Pallantla Poornima
@ 2019-02-06 16:18 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2019-02-06 16:18 UTC (permalink / raw)
To: Pallantla Poornima
Cc: dev, reshma.pattan, yipeng1.wang, sameh.gobriel,
bruce.richardson, pablo.de.lara.guarch, stable
On Wed, 6 Feb 2019 10:52:17 +0000
Pallantla Poornima <pallantlax.poornima@intel.com> wrote:
> + snprintf(name, sizeof(name), "test_hash%d_data",
> + hashtest_key_lens[table_index]);
It looks like %u should be used since hashtest_key_lens is unsigned
32 bit value.
Since the values in table are always small enough, I don't see why
this should go to stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-06 16:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-06 10:52 [dpdk-dev] [PATCH] hash: fix sprintf with snprintf Pallantla Poornima
2019-02-06 16:18 ` Stephen Hemminger
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).