* [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy
@ 2018-01-31 12:40 Amr Mokhtar
2018-01-31 14:53 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Amr Mokhtar @ 2018-01-31 12:40 UTC (permalink / raw)
To: dev; +Cc: Amr Mokhtar
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy
2018-01-31 12:40 [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy Amr Mokhtar
@ 2018-01-31 14:53 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2018-01-31 14:53 UTC (permalink / raw)
To: Amr Mokhtar; +Cc: dev
31/01/2018 13:40, Amr Mokhtar:
> 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>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-01-31 14:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 12:40 [dpdk-dev] [PATCH] app/testbbdev: fix buffer null termination due to strncpy Amr Mokhtar
2018-01-31 14:53 ` Thomas Monjalon
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).