public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Gilbert" <floppym@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/
Date: Sat,  5 Aug 2023 23:38:57 +0000 (UTC)	[thread overview]
Message-ID: <1691266090.128d5b32b301a552299feff7cc64e5f8f7c4fee7.floppym@gentoo> (raw)

commit:     128d5b32b301a552299feff7cc64e5f8f7c4fee7
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  5 19:11:58 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Aug  5 20:08:10 2023 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=128d5b32

erealpath: drop unused path_max variable

The SB_PATH_MAX macro is always defined, so this variable was pointless.

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 libsandbox/canonicalize.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/libsandbox/canonicalize.c b/libsandbox/canonicalize.c
index f742ed4..f282bdd 100644
--- a/libsandbox/canonicalize.c
+++ b/libsandbox/canonicalize.c
@@ -49,7 +49,6 @@ erealpath(const char *name, char *resolved)
 {
 	char *rpath, *dest, *recover;
 	const char *start, *end, *rpath_limit;
-	long int path_max;
 
 	if (name == NULL) {
 		/* As per Single Unix Specification V2 we must return an error if
@@ -66,16 +65,9 @@ erealpath(const char *name, char *resolved)
 		__set_errno(ENOENT);
 		return NULL;
 	}
-#ifdef SB_PATH_MAX
-	path_max = SB_PATH_MAX;
-#else
-	path_max = pathconf(name, _PC_PATH_MAX);
-	if (path_max <= 0)
-		path_max = 1024;
-#endif
 
 	if (resolved == NULL) {
-		rpath = xmalloc(path_max);
+		rpath = xmalloc(SB_PATH_MAX);
 	} else {
 		/* We can't handle resolving a buffer inline, so demand
 		 * separate read and write strings.
@@ -83,11 +75,11 @@ erealpath(const char *name, char *resolved)
 		sb_assert(name != resolved);
 		rpath = resolved;
 	}
-	rpath_limit = rpath + path_max;
+	rpath_limit = rpath + SB_PATH_MAX;
 
 	recover = NULL;
 	if (name[0] != '/') {
-		if (!egetcwd(rpath, path_max)) {
+		if (!egetcwd(rpath, SB_PATH_MAX)) {
 			rpath[0] = '\0';
 			goto error;
 		}
@@ -110,16 +102,16 @@ erealpath(const char *name, char *resolved)
 				if (lstat64(rpath, &st))
 					break;
 				if (S_ISLNK(st.st_mode)) {
-					ssize_t cnt = readlink(rpath, rpath, path_max);
+					ssize_t cnt = readlink(rpath, rpath, SB_PATH_MAX);
 					if (cnt == -1)
 						break;
 					rpath[cnt] = '\0';
 					if (p) {
 						size_t bytes_left = strlen(p);
-						if (bytes_left >= path_max)
+						if (bytes_left >= SB_PATH_MAX)
 							break;
 						strncat(rpath, name + (p - rpath + 1),
-							path_max - bytes_left - 1);
+							SB_PATH_MAX - bytes_left - 1);
 					}
 
 					/* Ok, we have a chance at something better.  If
@@ -187,10 +179,10 @@ erealpath(const char *name, char *resolved)
 					goto error;
 				}
 				new_size = rpath_limit - rpath;
-				if (end - start + 1 > path_max)
+				if (end - start + 1 > SB_PATH_MAX)
 					new_size += end - start + 1;
 				else
-					new_size += path_max;
+					new_size += SB_PATH_MAX;
 				new_rpath = (char *) xrealloc(rpath, new_size);
 				rpath = new_rpath;
 				rpath_limit = rpath + new_size;
@@ -213,7 +205,7 @@ erealpath(const char *name, char *resolved)
 
 error:
 	if (resolved)
-		snprintf(resolved, path_max, "%s", rpath);
+		snprintf(resolved, SB_PATH_MAX, "%s", rpath);
 	else
 		free(rpath);
 	free(recover);


             reply	other threads:[~2023-08-05 23:39 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-05 23:38 Mike Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-11  0:57 [gentoo-commits] proj/sandbox:master commit in: libsandbox/ Mike Gilbert
2025-03-10  1:17 Mike Gilbert
2025-03-09 18:09 Mike Gilbert
2025-03-09 18:09 Mike Gilbert
2025-03-09 18:09 Mike Gilbert
2025-02-23 20:07 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-02-22 19:49 Mike Gilbert
2025-01-08  2:12 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 19:19 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 19:19 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22 19:02 Mike Gilbert
2024-12-22 19:02 Mike Gilbert
2024-12-22  3:49 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14  4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-12-22  3:41 Mike Gilbert
2024-11-04 19:15 Mike Gilbert
2024-01-27 18:05 Mike Gilbert
2024-01-22 21:41 Mike Gilbert
2023-08-08 15:27 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-04  0:26 Mike Gilbert
2023-08-01 14:14 Mike Gilbert
2021-11-03 16:40 Mike Frysinger
2021-11-03 16:40 Mike Frysinger
2021-11-03  6:59 Mike Frysinger
2021-10-31 23:54 Mike Frysinger
2021-10-28  9:56 Mike Frysinger
2021-10-28  7:14 Mike Frysinger
2021-10-28  3:41 Mike Frysinger
2021-10-23 22:19 Mike Frysinger
2021-10-23  6:10 Mike Frysinger
2021-10-23  6:10 Mike Frysinger
2021-10-22  4:20 Mike Frysinger
2021-10-22  4:15 Mike Frysinger
2021-10-21 20:37 Mike Frysinger
2021-10-21 20:37 Mike Frysinger
2021-10-21  1:51 Mike Frysinger
2021-10-18 22:04 Mike Frysinger
2021-09-07 15:35 Michał Górny
2021-04-02 11:22 Sergei Trofimovich
2021-03-15 18:08 Sergei Trofimovich
2019-06-25  6:42 Sergei Trofimovich
2018-12-02 15:22 Michał Górny
2018-07-19 11:50 Michał Górny
2018-02-18 21:32 Michał Górny
2017-10-03 16:42 Ian Stakenvicius
2017-10-03 16:39 Michał Górny
2016-03-30  5:22 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-12-19 18:10 Mike Frysinger
2015-12-19 18:10 Mike Frysinger
2015-12-19  7:29 Mike Frysinger
2015-09-27  6:13 Mike Frysinger
2015-09-27  6:13 Mike Frysinger
2015-09-20  8:15 Mike Frysinger
2015-09-20  8:15 Mike Frysinger
2015-09-20  8:15 Mike Frysinger
2015-09-20  8:15 Mike Frysinger
2015-09-11  7:53 Mike Frysinger
2013-02-25  4:12 Mike Frysinger
2013-02-25  4:08 Mike Frysinger
2012-06-23 23:12 Mike Frysinger
2012-06-23 22:40 Mike Frysinger
2012-06-23 21:21 Mike Frysinger
2012-03-07  5:28 Mike Frysinger
2011-07-08 19:53 Mike Frysinger
2011-07-08 19:53 Mike Frysinger

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=1691266090.128d5b32b301a552299feff7cc64e5f8f7c4fee7.floppym@gentoo \
    --to=floppym@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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