diff options
author | 2023-08-05 15:18:53 -0400 | |
---|---|---|
committer | 2023-08-05 16:08:11 -0400 | |
commit | 8c3bc21729c3ad13295b586cd185b2b5da686731 (patch) | |
tree | 98911272cbf335d57ce75b400d13820f1e40cb22 | |
parent | erealpath: leave space for a trailing '\0' in readlink's buffer (diff) | |
download | sandbox-8c3bc21729c3ad13295b586cd185b2b5da686731.tar.gz sandbox-8c3bc21729c3ad13295b586cd185b2b5da686731.tar.bz2 sandbox-8c3bc21729c3ad13295b586cd185b2b5da686731.zip |
erealpath: use separate buffer for readlink
Fixes a compiler warning:
```
warning: passing argument 2 to 'restrict'-qualified parameter aliases with argument 1 [-Wrestrict]
```
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r-- | libsandbox/canonicalize.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libsandbox/canonicalize.c b/libsandbox/canonicalize.c index 6c9a2d6..f8d32f0 100644 --- a/libsandbox/canonicalize.c +++ b/libsandbox/canonicalize.c @@ -102,10 +102,12 @@ erealpath(const char *name, char *resolved) if (lstat64(rpath, &st)) break; if (S_ISLNK(st.st_mode)) { - ssize_t cnt = readlink(rpath, rpath, SB_PATH_MAX - 1); + char buffer[SB_PATH_MAX]; + ssize_t cnt = readlink(rpath, buffer, SB_PATH_MAX - 1); if (cnt == -1) break; - rpath[cnt] = '\0'; + buffer[cnt] = '\0'; + strcpy(rpath, buffer); if (p) { size_t bytes_left = strlen(p); if (bytes_left >= SB_PATH_MAX) |