From: Pallantla Poornima <pallantlax.poornima@intel.com>
To: dev@dpdk.org
Cc: reshma.pattan@intel.com, amr.mokhtar@intel.com,
Pallantla Poornima <pallantlax.poornima@intel.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH] app/testbbdev: fix sprintf with snprintf
Date: Mon, 4 Feb 2019 07:15:54 +0000 [thread overview]
Message-ID: <1549264554-2501-1-git-send-email-pallantlax.poornima@intel.com> (raw)
In-Reply-To: <y>
sprintf function is not secure as it doesn't check the length of string.
More secure function snprintf is used.
Fixes: f714a18885 ("app/testbbdev: add test application for bbdev")
Cc: stable@dpdk.org
Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
---
app/test-bbdev/test_bbdev.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/test-bbdev/test_bbdev.c b/app/test-bbdev/test_bbdev.c
index a914817bc..b9fc750d3 100644
--- a/app/test-bbdev/test_bbdev.c
+++ b/app/test-bbdev/test_bbdev.c
@@ -788,14 +788,14 @@ test_bbdev_driver_init(void)
/* Initialize the maximum amount of devices */
do {
- sprintf(name_tmp, "%s%i", "name_", num_devs);
+ snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs);
dev2 = rte_bbdev_allocate(name_tmp);
TEST_ASSERT(dev2 != NULL,
"Failed to initialize bbdev driver");
++num_devs;
} while (num_devs < (RTE_BBDEV_MAX_DEVS - 1));
- sprintf(name_tmp, "%s%i", "name_", num_devs);
+ snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs);
dev2 = rte_bbdev_allocate(name_tmp);
TEST_ASSERT(dev2 == NULL, "Failed to initialize bbdev driver number %d "
"more drivers than RTE_BBDEV_MAX_DEVS: %d ", num_devs,
@@ -804,7 +804,7 @@ test_bbdev_driver_init(void)
num_devs--;
while (num_devs >= num_devs_tmp) {
- sprintf(name_tmp, "%s%i", "name_", num_devs);
+ snprintf(name_tmp, sizeof(name_tmp), "%s%i", "name_", num_devs);
dev2 = rte_bbdev_get_named_dev(name_tmp);
TEST_ASSERT_SUCCESS(rte_bbdev_release(dev2),
"Failed to uninitialize bbdev driver %s ",
@@ -825,7 +825,7 @@ test_bbdev_driver_init(void)
TEST_ASSERT_FAIL(rte_bbdev_release(NULL),
"Failed to uninitialize bbdev driver with NULL bbdev");
- sprintf(name_tmp, "%s", "invalid_name");
+ snprintf(name_tmp, sizeof(name_tmp), "%s", "invalid_name");
dev2 = rte_bbdev_get_named_dev(name_tmp);
TEST_ASSERT_FAIL(rte_bbdev_release(dev2),
"Failed to uninitialize bbdev driver with invalid name");
--
2.17.2
next reply other threads:[~2019-02-04 7:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-04 7:15 Pallantla Poornima [this message]
2019-02-08 14:13 ` Ferruh Yigit
[not found] ` <7AE31235A30B41498D1C31348DC858BD5B533CD2@IRSMSX103.ger.corp.intel.com>
2019-02-15 11:30 ` Mokhtar, Amr
2019-02-11 13:35 ` Mokhtar, Amr
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=1549264554-2501-1-git-send-email-pallantlax.poornima@intel.com \
--to=pallantlax.poornima@intel.com \
--cc=amr.mokhtar@intel.com \
--cc=dev@dpdk.org \
--cc=reshma.pattan@intel.com \
--cc=stable@dpdk.org \
/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).