From: Pallantla Poornima <pallantlax.poornima@intel.com>
To: dev@dpdk.org
Cc: reshma.pattan@intel.com, liang.j.ma@intel.com,
peter.mccarthy@intel.com,
Pallantla Poornima <pallantlax.poornima@intel.com>,
stable@dpdk.org
Subject: [dpdk-dev] [PATCH] event/opdl: fix sprintf with snprintf
Date: Mon, 4 Feb 2019 07:18:02 +0000 [thread overview]
Message-ID: <1549264682-2979-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: 3c7f3dcfb0 ("event/opdl: add PMD main body and helper function")
Cc: stable@dpdk.org
Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
---
drivers/event/opdl/opdl_evdev.c | 7 ++++---
drivers/event/opdl/opdl_evdev_xstats.c | 7 +++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index a4f0bc8b6..d2d2be44b 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -422,16 +422,17 @@ opdl_dump(struct rte_eventdev *dev, FILE *f)
else
p_type = "????";
- sprintf(queue_id, "%02u", port->external_qid);
+ snprintf(queue_id, sizeof(queue_id), "%02u",
+ port->external_qid);
if (port->p_type == OPDL_REGULAR_PORT ||
port->p_type == OPDL_ASYNC_PORT)
- sprintf(total_cyc,
+ snprintf(total_cyc, sizeof(total_cyc),
" %'16"PRIu64"",
(cpg != 0 ?
port->port_stat[total_cycles] / cpg
: 0));
else
- sprintf(total_cyc,
+ snprintf(total_cyc, sizeof(total_cyc),
" ----");
fprintf(f,
"%4s %10u %8u %9s %'16"PRIu64" %'16"PRIu64" %s "
diff --git a/drivers/event/opdl/opdl_evdev_xstats.c b/drivers/event/opdl/opdl_evdev_xstats.c
index 0e6c6bd5e..27b3d8802 100644
--- a/drivers/event/opdl/opdl_evdev_xstats.c
+++ b/drivers/event/opdl/opdl_evdev_xstats.c
@@ -32,10 +32,9 @@ opdl_xstats_init(struct rte_eventdev *dev)
uint32_t index = (i * max_num_port_xstat) + j;
/* Name */
- sprintf(device->port_xstat[index].stat.name,
- "port_%02u_%s",
- i,
- port_xstat_str[j]);
+ snprintf(device->port_xstat[index].stat.name,
+ sizeof(device->port_xstat[index].stat.name),
+ "port_%02u_%s", i, port_xstat_str[j]);
/* ID */
device->port_xstat[index].id = index;
--
2.17.2
next reply other threads:[~2019-02-04 7:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-04 7:18 Pallantla Poornima [this message]
2019-03-11 6:51 ` Jerin Jacob Kollanukkaran
2019-03-11 13:52 ` Jerin Jacob Kollanukkaran
2019-03-12 8:39 ` Jerin Jacob Kollanukkaran
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=1549264682-2979-1-git-send-email-pallantlax.poornima@intel.com \
--to=pallantlax.poornima@intel.com \
--cc=dev@dpdk.org \
--cc=liang.j.ma@intel.com \
--cc=peter.mccarthy@intel.com \
--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).