patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	stable@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-stable] [PATCH 3/4] examples/mp_server: fix snprintf overflow
Date: Fri, 14 Aug 2020 12:00:44 +0100
Message-ID: <20200814110045.217724-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20200814110045.217724-1-bruce.richardson@intel.com>

When producing a printable mac address the buffer was appropriately sized
for holding the mac address exactly, but the actual snprintf included a
'\n' character at the end, which means that the snprintf technically is
getting truncated i.e. the \n would not be added due to lack of space.
This gets flagged as a problem by modern versions of gcc, e.g. on Ubuntu
20.04.

main.c:77:37: warning: ‘__builtin___snprintf_chk’ output truncated before the last format character [-Wformat-truncation=]
   77 |     "%02x:%02x:%02x:%02x:%02x:%02x\n",
      |                                     ^

Since the \n is getting stripped anyway, we can fix the issue by just
removing it from the printf string.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 examples/multi_process/client_server_mp/mp_server/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index 280dab8672..af5af672c3 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -74,7 +74,7 @@ get_printable_mac_addr(uint16_t port)
 			return err_address;
 		}
 		snprintf(addresses[port], sizeof(addresses[port]),
-				"%02x:%02x:%02x:%02x:%02x:%02x\n",
+				"%02x:%02x:%02x:%02x:%02x:%02x",
 				mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2],
 				mac.addr_bytes[3], mac.addr_bytes[4], mac.addr_bytes[5]);
 	}
-- 
2.25.1


  parent reply	other threads:[~2020-08-14 11:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200814110045.217724-1-bruce.richardson@intel.com>
2020-08-14 11:00 ` [dpdk-stable] [PATCH 1/4] power: make guest channel headers public Bruce Richardson
2020-08-14 11:05   ` Bruce Richardson
2020-08-14 11:00 ` [dpdk-stable] [PATCH 2/4] examples/vm_power_manager: fix string truncation warning Bruce Richardson
2020-08-14 11:00 ` Bruce Richardson [this message]
2020-08-14 15:01   ` [dpdk-stable] [dpdk-dev] [PATCH 3/4] examples/mp_server: fix snprintf overflow Stephen Hemminger
2020-08-14 11:00 ` [dpdk-stable] [PATCH 4/4] examples/mp_server: clear string truncation warning Bruce Richardson
     [not found] ` <20200821171017.50531-1-bruce.richardson@intel.com>
2020-08-21 17:10   ` [dpdk-stable] [PATCH v2 1/4] power: make guest channel headers public Bruce Richardson
2020-08-26 10:08     ` David Hunt
2020-10-05 21:44     ` Thomas Monjalon
2020-08-21 17:10   ` [dpdk-stable] [PATCH v2 2/4] examples/vm_power_manager: fix string truncation warning Bruce Richardson
2020-08-26 10:09     ` David Hunt
2020-08-21 17:10   ` [dpdk-stable] [PATCH v2 3/4] examples/mp_server: fix snprintf overflow Bruce Richardson
2020-10-09 11:22     ` [dpdk-stable] [dpdk-dev] " Nicolau, Radu
2020-08-21 17:10   ` [dpdk-stable] [PATCH v2 4/4] examples/mp_server: clear string truncation warning Bruce Richardson
2020-10-09 11:21     ` [dpdk-stable] [dpdk-dev] " Nicolau, Radu
     [not found] ` <20201028162702.969509-1-bruce.richardson@intel.com>
2020-10-28 16:27   ` [dpdk-stable] [PATCH v3 1/3] examples/vm_power_manager: fix " Bruce Richardson
2020-10-28 16:27   ` [dpdk-stable] [PATCH v3 2/3] examples/mp_server: fix snprintf overflow Bruce Richardson
2020-10-28 16:27   ` [dpdk-stable] [PATCH v3 3/3] examples/mp_server: clear string truncation warning Bruce Richardson

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=20200814110045.217724-4-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git