diff options
author | Érico Nogueira <ericonr@disroot.org> | 2021-04-27 10:09:45 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-05-03 16:46:10 -0300 |
commit | 77c1573dbceebf75203e4201615def9765599d87 (patch) | |
tree | d9a5545b804fee221c00125372d278efe1f9521d /sysdeps/unix/sysv/linux/fchmodat.c | |
parent | 19d83270fcd993cc349570164e21b06d57036704 (diff) | |
download | glibc-77c1573dbceebf75203e4201615def9765599d87.tar.gz glibc-77c1573dbceebf75203e4201615def9765599d87.tar.xz glibc-77c1573dbceebf75203e4201615def9765599d87.zip |
linux: use __fd_to_filename helper function instead of snprintf.
Change made to fchmodat and fexecve. There are tests using xasprintf instead of this helper as well, but this commit doesn't touch them.
Diffstat (limited to 'sysdeps/unix/sysv/linux/fchmodat.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/fchmodat.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/sysdeps/unix/sysv/linux/fchmodat.c b/sysdeps/unix/sysv/linux/fchmodat.c index f264f0c09d..5bd1eb96a5 100644 --- a/sysdeps/unix/sysv/linux/fchmodat.c +++ b/sysdeps/unix/sysv/linux/fchmodat.c @@ -18,6 +18,7 @@ #include <errno.h> #include <fcntl.h> +#include <fd_to_filename.h> #include <not-cancel.h> #include <stdio.h> #include <sys/stat.h> @@ -69,16 +70,8 @@ fchmodat (int fd, const char *file, mode_t mode, int flag) /* For most file systems, fchmod does not operate on O_PATH descriptors, so go through /proc. */ - char buf[32]; - if (__snprintf (buf, sizeof (buf), "/proc/self/fd/%d", pathfd) < 0) - { - /* This also may report strange error codes to the caller - (although snprintf really should not fail). */ - __close_nocancel (pathfd); - return -1; - } - - int ret = __chmod (buf, mode); + struct fd_to_filename filename; + int ret = __chmod (__fd_to_filename (pathfd, &filename), mode); if (ret != 0) { if (errno == ENOENT) |