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:stable-2.x commit in: libsandbox/
Date: Sun,  6 Aug 2023 00:40:53 +0000 (UTC)	[thread overview]
Message-ID: <1691282393.ae2cb037f024a2bd417c6a241d907390876ecc8a.floppym@gentoo> (raw)

commit:     ae2cb037f024a2bd417c6a241d907390876ecc8a
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  5 19:39:21 2023 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Aug  6 00:39:53 2023 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=ae2cb037

resolve_dirfd_path: use separate buffer for readlink

Fixes a compile warning:
```
warning: passing argument 2 to 'restrict'-qualified parameter aliases with argument 1 [-Wrestrict]
```

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
(cherry picked from commit 4b27824ee27013c672f75bce2066c950a71280d2)

 libsandbox/libsandbox.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 4edcf60..6a7368c 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -132,24 +132,25 @@ int resolve_dirfd_path(int dirfd, const char *path, char *resolved_path,
 
 	save_errno();
 
+	char fd_path[SB_PATH_MAX];
 	size_t at_len = resolved_path_len - 1 - 1 - (path ? strlen(path) : 0);
 	if (trace_pid) {
-		sprintf(resolved_path, "/proc/%i/fd/%i", trace_pid, dirfd);
+		sprintf(fd_path, "/proc/%i/fd/%i", trace_pid, dirfd);
 	} else {
 		/* If /proc was mounted by a process in a different pid namespace,
 		 * getpid cannot be used to create a valid /proc/<pid> path. Instead
 		 * use sb_get_fd_dir() which works in any case.
 		 */
-		sprintf(resolved_path, "%s/%i", sb_get_fd_dir(), dirfd);
+		sprintf(fd_path, "%s/%i", sb_get_fd_dir(), dirfd);
 	}
-	ssize_t ret = readlink(resolved_path, resolved_path, at_len);
+	ssize_t ret = readlink(fd_path, resolved_path, at_len);
 	if (ret == -1) {
 		/* see comments at end of check_syscall() */
 		if (errno_is_too_long()) {
 			restore_errno();
 			return 2;
 		}
-		sb_debug_dyn("AT_FD LOOKUP fail: %s: %s\n", resolved_path, strerror(errno));
+		sb_debug_dyn("AT_FD LOOKUP fail: %s: %s\n", fd_path, strerror(errno));
 		/* If the fd isn't found, some guys (glibc) expect errno */
 		if (errno == ENOENT)
 			errno = EBADF;


             reply	other threads:[~2023-08-06  0:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-06  0:40 Mike Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-01-08  2:12 [gentoo-commits] proj/sandbox:stable-2.x commit in: libsandbox/ Mike Gilbert
2024-12-22 19:19 Mike Gilbert
2024-12-22 19:19 Mike Gilbert
2024-12-22  3:49 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-06  0:40 Mike Gilbert
2023-08-06  0:40 Mike Gilbert
2023-08-06  0:40 Mike Gilbert
2023-08-04  0:27 Mike Gilbert
2023-08-01 14:15 Mike Gilbert

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=1691282393.ae2cb037f024a2bd417c6a241d907390876ecc8a.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