[PATCH v10 6/9] test: fix impossible format-truncation in cfgfiles
Marat Khalili
marat.khalili at huawei.com
Fri Jan 2 15:47:31 CET 2026
> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Monday 29 December 2025 21:59
> To: dev at dpdk.org
> Cc: Stephen Hemminger <stephen at networkplumber.org>; stable at dpdk.org; Anatoly Burakov
> <anatoly.burakov at intel.com>; Cristian Dumitrescu <cristian.dumitrescu at intel.com>; Bruce Richardson
> <bruce.richardson at intel.com>
> Subject: [PATCH v10 6/9] test: fix impossible format-truncation in cfgfiles
>
> Although, it is not possible on Linux (which always uses /tmp)
> the compiler complains about possible snprintf() truncation.
>
> Use existing code to make empty tmp file which puts the
> OS specific code in one spot and avoids any races if
> two tests are run at once.
>
> Fixes: be22019a58c4 ("test: restore cfgfile tests")
> Cc: stable at dpdk.org
>
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
> ---
> app/test/test_cfgfile.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/app/test/test_cfgfile.c b/app/test/test_cfgfile.c
> index b189d9d7a5..eabf155404 100644
> --- a/app/test/test_cfgfile.c
> +++ b/app/test/test_cfgfile.c
> @@ -178,12 +178,8 @@ test_cfgfile_realloc_sections(void)
> ret = remove(filename);
> TEST_ASSERT_SUCCESS(ret, "Failed to remove file");
>
> - char tmp[PATH_MAX] = "/tmp/";
> -#ifdef RTE_EXEC_ENV_WINDOWS
> - ret = GetTempPathA(sizeof(tmp), tmp);
> - TEST_ASSERT(ret > 0, "Failed to get tmp directory");
> -#endif
> - snprintf(filename, sizeof(filename), "%s%s", tmp, "cfg_save.ini");
> + ret = make_tmp_file(filename, "save", "");
> + TEST_ASSERT(ret == 0, "Failed to make empty tmp filename for save");
>
> ret = rte_cfgfile_save(cfgfile, filename);
> TEST_ASSERT_SUCCESS(ret, "Failed to save to %s", filename);
> --
> 2.51.0
>
Acked-by: Marat Khalili <marat.khalili at huawei.com>
More information about the stable
mailing list