DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Kulasek <tomaszx.kulasek@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] app/testpmd: fix strcat can overrun fixed-size string
Date: Mon, 11 Apr 2016 18:03:48 +0200	[thread overview]
Message-ID: <1460390628-4716-1-git-send-email-tomaszx.kulasek@intel.com> (raw)

CID 13307 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
fixed_size_dest: You might overrun the 128 byte fixed-size string fwd_modes
by copying fwd_eng->fwd_mode_name without checking the length.

Fixes: 769ce6b17835 ("app/testpmd: list forwarding engines")

Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 app/test-pmd/config.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b1bbec6..fff2d96 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1673,8 +1673,10 @@ list_pkt_forwarding_modes(void)
 
 	if (strlen (fwd_modes) == 0) {
 		while ((fwd_eng = fwd_engines[i++]) != NULL) {
-			strcat(fwd_modes, fwd_eng->fwd_mode_name);
-			strcat(fwd_modes, separator);
+			strncat(fwd_modes, fwd_eng->fwd_mode_name, sizeof(fwd_modes) -
+					strlen(fwd_modes) - 1);
+			strncat(fwd_modes, separator, sizeof(fwd_modes) - strlen(fwd_modes)
+					- 1);
 		}
 		fwd_modes[strlen(fwd_modes) - strlen(separator)] = '\0';
 	}
-- 
1.7.9.5

             reply	other threads:[~2016-04-11 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-11 16:03 Tomasz Kulasek [this message]
2016-04-27 15:01 ` Thomas Monjalon

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=1460390628-4716-1-git-send-email-tomaszx.kulasek@intel.com \
    --to=tomaszx.kulasek@intel.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).