From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5CDCC15800A for ; Sun, 6 Aug 2023 00:40:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 651EB2BC014; Sun, 6 Aug 2023 00:40:55 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4BD5C2BC014 for ; Sun, 6 Aug 2023 00:40:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 83572335D97 for ; Sun, 6 Aug 2023 00:40:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C74EFF0E for ; Sun, 6 Aug 2023 00:40:52 +0000 (UTC) From: "Mike Gilbert" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Gilbert" Message-ID: <1691282392.0d063e31d575fb0a94b56219cafb0a198215b7aa.floppym@gentoo> Subject: [gentoo-commits] proj/sandbox:stable-2.x commit in: libsandbox/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsandbox/canonicalize.c X-VCS-Directories: libsandbox/ X-VCS-Committer: floppym X-VCS-Committer-Name: Mike Gilbert X-VCS-Revision: 0d063e31d575fb0a94b56219cafb0a198215b7aa X-VCS-Branch: stable-2.x Date: Sun, 6 Aug 2023 00:40:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5f9cc872-25ab-472c-a2c5-d15c514a3807 X-Archives-Hash: 664a17aec0e008d27248c5bb41d80b45 commit: 0d063e31d575fb0a94b56219cafb0a198215b7aa Author: Mike Gilbert gentoo org> AuthorDate: Sat Aug 5 19:11:58 2023 +0000 Commit: Mike Gilbert gentoo org> CommitDate: Sun Aug 6 00:39:52 2023 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=0d063e31 erealpath: drop unused path_max variable The SB_PATH_MAX macro is always defined, so this variable was pointless. Signed-off-by: Mike Gilbert gentoo.org> (cherry picked from commit 128d5b32b301a552299feff7cc64e5f8f7c4fee7) 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);