fileio: mask off O_NOFOLLOW in xfopenat_regular() for fd_reopen()

in a similar fashion as xopenat_full()
This commit is contained in:
Mike Yuan
2025-11-03 22:32:25 +01:00
parent 9218e4eacc
commit eaebc33220
+2 -2
View File
@@ -1011,7 +1011,7 @@ static int xfopenat_regular(int dir_fd, const char *path, const char *mode, int
assert(mode);
assert(ret);
if (dir_fd == AT_FDCWD && open_flags == 0 && path)
if (dir_fd == AT_FDCWD && path && open_flags == 0)
f = fopen(path, mode);
else {
_cleanup_close_ int fd = -EBADF;
@@ -1029,7 +1029,7 @@ static int xfopenat_regular(int dir_fd, const char *path, const char *mode, int
if (dir_fd == AT_FDCWD)
return -EBADF;
fd = fd_reopen(dir_fd, mode_flags | open_flags);
fd = fd_reopen(dir_fd, (mode_flags | open_flags) & ~O_NOFOLLOW);
if (fd < 0)
return fd;
}