DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andy Green <andy@warmcat.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v5 02/16] net/nfp: solve buffer overflow
Date: Sat, 12 May 2018 09:47:54 +0800	[thread overview]
Message-ID: <152608967428.121204.9699484562259656056.stgit@localhost.localdomain> (raw)
In-Reply-To: <152608956198.121204.14844325841690943774.stgit@localhost.localdomain>

/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c: In
function ‘nfp_pf_pci_probe’:
/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3160:
23: error: ‘%s’ directive writing up to 99 bytes into a
region of size 76 [-Werror=format-overflow=]
  sprintf(fw_name, "%s/%s.nffw", DEFAULT_FW_PATH, serial);

Note fw_buf still has to increase somewhat even after
restricting serial[], since otherwise:

/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c: In
function ‘nfp_pf_pci_probe’:
/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3176:23:
error: ‘%s’ directive writing up to 99 bytes into a region
of size 76 [-Werror=format-overflow=]
  sprintf(fw_name, "%s/%s", DEFAULT_FW_PATH, card);
                       ^~
/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3262:32:
  err = nfp_fw_upload(dev, nsp, card_desc);
                                ~~~~~~~~~
/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3176:2:
note: ‘sprintf’ output between 25 and 124 bytes into a
destination of size 100
  sprintf(fw_name, "%s/%s", DEFAULT_FW_PATH, card);

Signed-off-by: Andy Green <andy@warmcat.com>
Fixes: 896c265ef954 ("net/nfp: use new CPP interface")
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/net/nfp/nfp_net.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 048324ec9..78113b41b 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3144,8 +3144,8 @@ nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card)
 	struct nfp_cpp *cpp = nsp->cpp;
 	int fw_f;
 	char *fw_buf;
-	char fw_name[100];
-	char serial[100];
+	char fw_name[125];
+	char serial[40];
 	struct stat file_stat;
 	off_t fsize, bytes;
 

  parent reply	other threads:[~2018-05-12  1:47 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-12  1:47 [dpdk-dev] [PATCH v5 00/16] Fix default build on gcc8.0.1 Andy Green
2018-05-12  1:47 ` [dpdk-dev] [PATCH v5 01/16] devtools/check-git: provide more generic grep pattern Andy Green
2018-05-12  1:47 ` Andy Green [this message]
2018-05-12  1:47 ` [dpdk-dev] [PATCH v5 03/16] bus/pci: replace strncpy dangerous code Andy Green
2018-05-15  6:12   ` Yao, Lei A
2018-05-15  7:31     ` [dpdk-dev] [PATCH] bus/pci: correct the earlier strlcpy conversion Andy Green
2018-05-15 10:51       ` Andrew Rybchenko
2018-05-15 13:19         ` Thomas Monjalon
2018-05-15  7:32     ` [dpdk-dev] [PATCH v5 03/16] bus/pci: replace strncpy dangerous code Andy Green
2018-05-15  8:18       ` Yao, Lei A
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 04/16] bus/dpaa: solve inconsistent struct alignment Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 05/16] net/axgbe: solve broken eeprom string comp Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 06/16] net/nfp/nfpcore: solve strncpy misuse Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 07/16] net/nfp/nfpcore: off-by-one and no NUL on strncpy use Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 08/16] net/nfp: don't memcpy out of source range Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 09/16] net/qede: strncpy length constant and NUL Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 10/16] net/qede: solve broken strncpy Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 11/16] net/sfc: make sure that copied stats name is NUL-terminated Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 12/16] net/vdev_netvsc: readlink inputs cannot be aliased Andy Green
2018-05-13  7:20   ` Matan Azrad
2018-05-14  4:54     ` Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 13/16] net/vdev_netvsc: 3 x strncpy misuse Andy Green
2018-05-13  7:47   ` Matan Azrad
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 14/16] app/proc-info: sprintf overrun bug Andy Green
2018-05-12  1:48 ` [dpdk-dev] [PATCH v5 15/16] app/test-bbdev: strcpy ok for allocated string Andy Green
2018-05-12  1:49 ` [dpdk-dev] [PATCH v5 16/16] " Andy Green
2018-05-14  4:59 ` [dpdk-dev] [PATCH v6 00/16] Fix default build on gcc8.0.1 Andy Green
2018-05-14  4:59   ` [dpdk-dev] [PATCH v6 01/16] devtools/check-git: provide more generic grep pattern Andy Green
2018-05-14 16:28     ` Ferruh Yigit
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 02/16] net/nfp: solve buffer overflow Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 03/16] bus/pci: replace strncpy dangerous code Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 04/16] bus/dpaa: solve inconsistent struct alignment Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 05/16] net/axgbe: solve broken eeprom string comp Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 06/16] net/nfp/nfpcore: solve strncpy misuse Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 07/16] net/nfp/nfpcore: off-by-one and no NUL on strncpy use Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 08/16] net/nfp: don't memcpy out of source range Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 09/16] net/qede: strncpy length constant and NUL Andy Green
2018-05-14 20:16     ` Ferruh Yigit
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 10/16] net/qede: solve broken strncpy Andy Green
2018-05-14 20:20     ` Ferruh Yigit
2018-05-14 21:14       ` Ferruh Yigit
2018-05-14 23:04         ` Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 11/16] net/sfc: make sure that copied stats name is NUL-terminated Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 12/16] net/vdev_netvsc: readlink inputs cannot be aliased Andy Green
2018-05-14  5:00   ` [dpdk-dev] [PATCH v6 13/16] net/vdev_netvsc: convert snprintf to strlcpy Andy Green
2018-05-14  5:01   ` [dpdk-dev] [PATCH v6 14/16] app/proc-info: sprintf overrun bug Andy Green
2018-05-14 20:31     ` Ferruh Yigit
2018-05-14  5:01   ` [dpdk-dev] [PATCH v6 15/16] app/test-bbdev: strcpy ok for allocated string Andy Green
2018-05-14 20:42     ` Ferruh Yigit
2018-05-14 20:56       ` Ferruh Yigit
2018-05-14 21:01         ` Ferruh Yigit
2018-05-14  5:01   ` [dpdk-dev] [PATCH v6 16/16] " Andy Green
2018-05-14 21:03     ` Ferruh Yigit
2018-05-14 21:29   ` [dpdk-dev] [PATCH v6 00/16] Fix default build on gcc8.0.1 Ferruh Yigit

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=152608967428.121204.9699484562259656056.stgit@localhost.localdomain \
    --to=andy@warmcat.com \
    --cc=dev@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).