[v2] 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>
---
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(-)
Comments
Sorry for the late reply, but I noticed the test folder is recently moved under app so you may need a rebase.
Please keep my ack after rebase: Acked-by: Yipeng Wang <yipeng1.wang at intel.com>
>-----Original Message-----
>From: Poornima, PallantlaX
>Sent: Monday, March 25, 2019 7:43 AM
>To: dev@dpdk.org
>Cc: Pattan, Reshma <reshma.pattan@intel.com>; Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh
><sameh.gobriel@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>; De Lara Guarch, Pablo
><pablo.de.lara.guarch@intel.com>; stephen@networkplumber.org; stable@dpdk.org
>Subject: RE: [PATCH v2] hash: fix sprintf with snprintf
>
>Hi,
>
>>-----Original Message-----
>>From: Poornima, PallantlaX
>>Sent: Thursday, February 14, 2019 6:28 PM
>>To: dev@dpdk.org
>>Cc: Pattan, Reshma <reshma.pattan@intel.com>; Wang, Yipeng1
>><yipeng1.wang@intel.com>; Gobriel, Sameh <sameh.gobriel@intel.com>;
>>Richardson, Bruce <bruce.richardson@intel.com>; De Lara Guarch, Pablo
>><pablo.de.lara.guarch@intel.com>; stephen@networkplumber.org;
>>Poornima, PallantlaX <pallantlax.poornima@intel.com>; stable@dpdk.org
>>Subject: [PATCH v2] hash: fix sprintf with snprintf
>>
>>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.
>>---
>
>
>Request for ACK please if there are no comments
>
>Regards,
>Poornima
@@ -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)