From 36514d8dfafa22dbf0b784f705086e279e1c1e41 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 8 Feb 2022 22:54:01 -0800 Subject: [PATCH] eal: remove size for setting runtime directory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The size argument to eal_set_runtime_dir is useless and was being used incorrectly in strlcpy. It worked only because all callers passed PATH_MAX which is same as sizeof the destination runtime_dir. Note: this is an internal API so no user exposed change. Signed-off-by: Stephen Hemminger Reviewed-by: Morten Brørup Acked-by: Bruce Richardson --- lib/eal/common/eal_common_config.c | 7 ++----- lib/eal/common/eal_private.h | 4 +--- lib/eal/freebsd/eal.c | 2 +- lib/eal/linux/eal.c | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/eal/common/eal_common_config.c b/lib/eal/common/eal_common_config.c index 6d19aadb20..3cef43a4f7 100644 --- a/lib/eal/common/eal_common_config.c +++ b/lib/eal/common/eal_common_config.c @@ -29,12 +29,9 @@ rte_eal_get_runtime_dir(void) } int -eal_set_runtime_dir(char *run_dir, size_t size) +eal_set_runtime_dir(const char *run_dir) { - size_t str_size; - - str_size = strlcpy(runtime_dir, run_dir, size); - if (str_size >= size) { + if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) { RTE_LOG(ERR, EAL, "Runtime directory string too long\n"); return -1; } diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 36bcc0b5a4..734f1f334b 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -681,13 +681,11 @@ eal_mem_set_dump(void *virt, size_t size, bool dump); * * @param run_dir * The new runtime directory path of DPDK - * @param size - * The size of the new runtime directory path in bytes. * @return * 0 on success, (-1) on failure. */ int -eal_set_runtime_dir(char *run_dir, size_t size); +eal_set_runtime_dir(const char *run_dir); /** * Get the internal configuration structure. diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index a1cd2462db..503e276dc2 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -123,7 +123,7 @@ eal_create_runtime_dir(void) return -1; } - if (eal_set_runtime_dir(run_dir, sizeof(run_dir))) + if (eal_set_runtime_dir(run_dir)) return -1; return 0; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 9c8395ab14..e37372ac73 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -137,7 +137,7 @@ eal_create_runtime_dir(void) return -1; } - if (eal_set_runtime_dir(run_dir, sizeof(run_dir))) + if (eal_set_runtime_dir(run_dir)) return -1; return 0; -- 2.20.1