hash: fix sprintf with snprintf
Checks
Commit Message
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(-)
Comments
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.
@@ -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)