From: Bruce Richardson <bruce.richardson@intel.com>
To: Pallantla Poornima <pallantlax.poornima@intel.com>
Cc: dev@dpdk.org, reshma.pattan@intel.com, david.hunt@intel.com,
stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] test/distributor: fix sprintf with snprintf
Date: Wed, 6 Feb 2019 10:48:16 +0000 [thread overview]
Message-ID: <20190206104816.GA79664@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <1549449547-32343-1-git-send-email-pallantlax.poornima@intel.com>
On Wed, Feb 06, 2019 at 10:39:07AM +0000, Pallantla Poornima wrote:
> sprintf function is not secure as it doesn't check the length of string.
> More secure function snprintf is used.
>
> Fixes: f74df2c57e ("test/distributor: test single and burst API")
> Cc: stable@dpdk.org
>
> Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
> ---
> test/test/test_distributor.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/test/test/test_distributor.c b/test/test/test_distributor.c
> index 98919ec0c..03df32b05 100644
> --- a/test/test/test_distributor.c
> +++ b/test/test/test_distributor.c
> @@ -642,9 +642,11 @@ test_distributor(void)
>
> worker_params.dist = dist[i];
> if (i)
> - sprintf(worker_params.name, "burst");
> + snprintf(worker_params.name,
> + sizeof(worker_params.name), "burst");
> else
> - sprintf(worker_params.name, "single");
> + snprintf(worker_params.name,
> + sizeof(worker_params.name), "single");
>
> rte_eal_mp_remote_launch(handle_work,
> &worker_params, SKIP_MASTER);
> --
While not wrong here, I think changing these to string copies using
"strlcpy" might be better, since this is constant text in each case, and no
printf formatting is actually needed.
/Bruce
prev parent reply other threads:[~2019-02-06 10:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 10:39 Pallantla Poornima
2019-02-06 10:48 ` Bruce Richardson [this message]
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=20190206104816.GA79664@bricha3-MOBL.ger.corp.intel.com \
--to=bruce.richardson@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=pallantlax.poornima@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).