From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Pallantla Poornima <pallantlax.poornima@intel.com>, dev@dpdk.org
Cc: reshma.pattan@intel.com, alejandro.lucero@netronome.com, stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/nfp: fix sprintf with snprintf
Date: Fri, 1 Mar 2019 15:25:48 +0000 [thread overview]
Message-ID: <980bea85-f3d4-0fb4-0195-41154c531db4@intel.com> (raw)
In-Reply-To: <1549264928-3935-1-git-send-email-pallantlax.poornima@intel.com>
On 2/4/2019 7:22 AM, Pallantla Poornima wrote:
> sprintf function is not secure as it doesn't check the length of string.
> More secure function snprintf is used.
Can you please update title to reflect what actually fixed, something like:
net/nfp: fix possible buffer overflow
>
> Fixes: 896c265ef9 ("net/nfp: use new CPP interface")
> Fixes: c4171b520b ("net/nfp: support PF multiport")
> Cc: stable@dpdk.org
>
> Signed-off-by: Pallantla Poornima <pallantlax.poornima@intel.com>
> ---
> drivers/net/nfp/nfp_net.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index a791e95e2..dd8cae135 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -3318,9 +3318,9 @@ nfp_pf_create_dev(struct rte_pci_device *dev, int port, int ports,
> return -ENOMEM;
>
> if (ports > 1)
> - sprintf(port_name, "%s_port%d", dev->device.name, port);
> + snprintf(port_name, 100, "%s_port%d", dev->device.name, port);
> else
> - sprintf(port_name, "%s", dev->device.name);
> + snprintf(port_name, 100, "%s", dev->device.name);
This can be done as strlcat() but I leave this to Alejandro, unless you don't
get his feedback I think good to continue as it is.
<...>
> @@ -3530,8 +3533,9 @@ nfp_fw_setup(struct rte_pci_device *dev, struct nfp_cpp *cpp,
>
> PMD_DRV_LOG(INFO, "Port speed: %u", nfp_eth_table->ports[0].speed);
>
> - sprintf(card_desc, "nic_%s_%dx%d.nffw", nfp_fw_model,
> - nfp_eth_table->count, nfp_eth_table->ports[0].speed / 1000);
> + snprintf(card_desc, sizeof(card_desc), "nic_%s_%dx%d.nffw",
> + nfp_fw_model, nfp_eth_table->count,
> + nfp_eth_table->ports[0].speed / 1000);
Can you please fix the indentation?
prev parent reply other threads:[~2019-03-01 15:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-04 7:22 Pallantla Poornima
2019-03-01 15:25 ` Ferruh Yigit [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=980bea85-f3d4-0fb4-0195-41154c531db4@intel.com \
--to=ferruh.yigit@intel.com \
--cc=alejandro.lucero@netronome.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).