From: Amr Mokhtar <amr.mokhtar@intel.com>
To: dev@dpdk.org
Cc: Amr Mokhtar <amr.mokhtar@intel.com>
Subject: [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy
Date: Wed, 31 Jan 2018 12:40:40 +0000 [thread overview]
Message-ID: <1517402440-129255-1-git-send-email-amr.mokhtar@intel.com> (raw)
use snprintf instead of strncpy to ensure null termination when
copying test_vector_filename from cmd arguments.
Coverity issue: 257001
Fixes: f714a18885a6 ("app/testbbdev: add test application for bbdev")
Signed-off-by: Amr Mokhtar <amr.mokhtar@intel.com>
---
app/test-bbdev/main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/test-bbdev/main.c b/app/test-bbdev/main.c
index 3f542a8..41b54bb 100644
--- a/app/test-bbdev/main.c
+++ b/app/test-bbdev/main.c
@@ -226,8 +226,9 @@ parse_args(int argc, char **argv, struct test_params *tp)
TEST_ASSERT(strlen(optarg) > 0,
"Config file name is null");
- strncpy(tp->test_vector_filename, optarg,
- sizeof(tp->test_vector_filename));
+ snprintf(tp->test_vector_filename,
+ sizeof(tp->test_vector_filename),
+ "%s", optarg);
break;
case 'l':
TEST_ASSERT(strlen(optarg) > 0,
--
2.7.4
next reply other threads:[~2018-01-31 12:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 12:40 Amr Mokhtar [this message]
2018-01-31 14:53 ` 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=1517402440-129255-1-git-send-email-amr.mokhtar@intel.com \
--to=amr.mokhtar@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).