Several tests lookup the current file prefix and format up a filename argument. Avoid any possible format overflows by using new file prefix function.
Signed-off-by: Stephen Hemminger <[email protected]> Acked-by: Marat Khalili <[email protected]> --- app/test/test_mp_secondary.c | 14 ++++---------- app/test/test_pdump.c | 13 ++++--------- app/test/test_timer_secondary.c | 12 ++++-------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/app/test/test_mp_secondary.c b/app/test/test_mp_secondary.c index 9b4b9812c3..218eacb3bf 100644 --- a/app/test/test_mp_secondary.c +++ b/app/test/test_mp_secondary.c @@ -67,17 +67,11 @@ run_secondary_instances(void) { int ret = 0; char core_str[10]; + const char *prefix; -#ifdef RTE_EXEC_ENV_LINUX - char tmp[PATH_MAX] = {0}; - char prefix[PATH_MAX] = {0}; - - get_current_prefix(tmp, sizeof(tmp)); - - snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp); -#else - const char *prefix = ""; -#endif + prefix = file_prefix_arg(); + if (prefix == NULL) + return -1; /* good case, using secondary */ const char *argv1[] = { diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c index c084e20742..824caef2d4 100644 --- a/app/test/test_pdump.c +++ b/app/test/test_pdump.c @@ -174,16 +174,11 @@ run_pdump_server_tests(void) { int ret = 0; char core_str[10]; + const char *prefix; -#ifdef RTE_EXEC_ENV_LINUX - char tmp[PATH_MAX] = { 0 }; - char prefix[PATH_MAX] = { 0 }; - - get_current_prefix(tmp, sizeof(tmp)); - snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp); -#else - const char *prefix = ""; -#endif + prefix = file_prefix_arg(); + if (prefix == NULL) + return -1; /* good case, using secondary */ const char *const argv1[] = { diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_secondary.c index 8bff904ed4..0fc07dcbad 100644 --- a/app/test/test_timer_secondary.c +++ b/app/test/test_timer_secondary.c @@ -51,16 +51,12 @@ static int timer_secondary_spawn_wait(unsigned int lcore) { char core_str[10]; -#ifdef RTE_EXEC_ENV_LINUXAPP - char tmp[PATH_MAX] = {0}; - char prefix[PATH_MAX] = {0}; + const char *prefix; - get_current_prefix(tmp, sizeof(tmp)); + prefix = file_prefix_arg(); + if (prefix == NULL) + return -1; - snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp); -#else - const char *prefix = ""; -#endif char const *argv[] = { prgname, "-l", core_str, -- 2.51.0

