RE: [PATCH v10 8/9] test: fix overflow warnings in common code

Marat Khalili
2026-01-02T14:54:55Z

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday 29 December 2025 21:59
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Anatoly Burakov <anatoly.burakov@intel.com>;
> Reshma Pattan <reshma.pattan@intel.com>; Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
> Subject: [PATCH v10 8/9] test: fix overflow warnings in common code
>
> Several tests lookup the current file prefix and
> format up a filename argument. Avoid any possible format
> overflows by allowing for bigger string.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> 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 f3694530a8..fc295323f2 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 coremask[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 9f7769707e..cd044f0f69 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 coremask[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 4e220559b4..bd618b3cfc 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 coremask[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,
> "-c", coremask,
> --
> 2.51.0
>

Acked-by: Marat Khalili <marat.khalili@huawei.com>

(commit message looks slightly out of sync)