[dpdk-dev] app/testbbdev: fix buffer null termination due to strncpy
Checks
Commit Message
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(-)
Comments
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
@@ -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,