commit: 6b34ab545c41e72024402a082eca52379c36035f
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 4 21:17:04 2024 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Dec 22 03:43:25 2024 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=6b34ab54
resolve_dirfd_path: avoid appending a trailing / if path is empty
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
(cherry picked from commit beb84c66b725b52d5152bb25521671b332520cc9)
libsandbox/libsandbox.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 18e9626..c4bfac8 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -159,8 +159,9 @@ int resolve_dirfd_path(int dirfd, const char *path, char
*resolved_path,
free(fd_path);
return -1;
}
- resolved_path[ret] = '/';
- resolved_path[ret + 1] = '\0';
+ if (path && path[0])
+ resolved_path[ret++] = '/';
+ resolved_path[ret] = '\0';
if (path)
strcat(resolved_path, path);