DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pallantla Poornima <pallantlax.poornima@intel.com>
To: dev@dpdk.org
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 <pallantlax.poornima@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v3] app/test/hash: fix sprintf with snprintf
Date: Tue, 26 Mar 2019 10:27:23 +0000	[thread overview]
Message-ID: <1553596043-21363-1-git-send-email-pallantlax.poornima@intel.com> (raw)
Message-ID: <20190326102723.s-6imEksbrhLC2QUEX-CLFhFuvDlVWtQT7X7MFpHUaI@z> (raw)
In-Reply-To: <1550149062-14300-1-git-send-email-pallantlax.poornima@intel.com>

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>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
---
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


  parent reply	other threads:[~2019-03-26 10:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 12:57 [dpdk-dev] [PATCH v2] hash: " 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 ` Pallantla Poornima [this message]
2019-03-26 10:27   ` [dpdk-dev] [PATCH v3] app/test/hash: " Pallantla Poornima
2019-04-04 23:59   ` Thomas Monjalon
2019-04-04 23:59     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1553596043-21363-1-git-send-email-pallantlax.poornima@intel.com \
    --to=pallantlax.poornima@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=reshma.pattan@intel.com \
    --cc=sameh.gobriel@intel.com \
    --cc=stable@dpdk.org \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).