DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
	talshn@mellanox.com, "Morten Brørup" <mb@smartsharesystems.com>
Subject: [PATCH 1/2] eal: remove size for eal_set_runtime_dir
Date: Wed,  2 Feb 2022 22:00:24 -0800	[thread overview]
Message-ID: <20220203060025.881552-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20220203060025.881552-1-stephen@networkplumber.org>

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.

Fixes: 57a2efb30477 ("eal: move OS common config objects")
Cc: talshn@mellanox.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Morten Brørup<mb@smartsharesystems.com>
---
 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 1c4c4dd585d0..62a9d7a198db 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 36bcc0b5a492..734f1f334b69 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 a1cd2462db1b..503e276dc27f 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 60b49248388e..f2551c64b10c 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.34.1


  reply	other threads:[~2022-02-03  6:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 23:39 [RFC] eal: support systemd service convention for runtime directory Stephen Hemminger
2021-12-26 12:20 ` Morten Brørup
2022-01-05 18:01   ` [RFC] eal: remove size for eal_set_runtime_dir Stephen Hemminger
2022-01-05 20:04     ` Morten Brørup
2022-01-07 12:07 ` [RFC] eal: support systemd service convention for runtime directory Bruce Richardson
2022-02-02 21:03   ` Thomas Monjalon
2022-02-02 21:07     ` Stephen Hemminger
2022-02-03  6:00 ` [PATCH 0/2] better support of configuring " Stephen Hemminger
2022-02-03  6:00   ` Stephen Hemminger [this message]
2022-02-03  6:00   ` [PATCH 2/2] eal: support systemd service convention for " Stephen Hemminger
2022-02-03 11:37     ` Bruce Richardson
2022-02-05 17:10   ` [PATCH v2 0/2] eal: support configuring " Stephen Hemminger
2022-02-05 17:11     ` [PATCH v2 1/2] eal: remove size for eal_set_runtime_dir Stephen Hemminger
2022-02-05 17:11     ` [PATCH v2 2/2] eal: support systemd service convention for runtime directory Stephen Hemminger
2022-02-08  4:43     ` [PATCH v2 0/2] eal: support configuring " Stephen Hemminger
2022-02-08 10:48       ` Bruce Richardson
2022-02-09  6:54 ` [PATCH v3 0/3] " Stephen Hemminger
2022-02-09  6:54   ` [PATCH v3 1/3] eal: remove size for eal_set_runtime_dir Stephen Hemminger
2022-02-09  6:54   ` [PATCH v3 2/3] eal: support systemd service convention for runtime directory Stephen Hemminger
2022-02-09  6:54   ` [PATCH v3 3/3] eal: move common filesystem setup code into one file Stephen Hemminger
2022-02-09  9:18     ` Bruce Richardson
2022-02-09 18:14   ` [PATCH v3 0/3] eal: support configuring runtime directory Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220203060025.881552-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=talshn@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).