Skip to content

Commit cbd703a

Browse files
committed
Handle AT_SYMLINK_NOFOLLOW in __syscall_faccessat
The assertion in __syscall_faccessat only allowed AT_EACCESS, causing a crash when AT_SYMLINK_NOFOLLOW was passed (e.g. by GLib's g_local_file_query_exists which uses AT_EACCESS | AT_SYMLINK_NOFOLLOW). Accept AT_SYMLINK_NOFOLLOW and use it to control whether symlinks are followed during the path lookup.
1 parent 7840305 commit cbd703a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/lib/libsyscall.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,14 +930,15 @@ var SyscallsLibrary = {
930930
__syscall_faccessat: (dirfd, path, amode, flags) => {
931931
path = SYSCALLS.getStr(path);
932932
#if ASSERTIONS
933-
assert(!flags || flags == {{{ cDefs.AT_EACCESS }}});
933+
assert(!flags || !(flags & ~({{{ cDefs.AT_EACCESS }}} | {{{ cDefs.AT_SYMLINK_NOFOLLOW }}})));
934934
#endif
935935
path = SYSCALLS.calculateAt(dirfd, path);
936936
if (amode & ~{{{ cDefs.S_IRWXO }}}) {
937937
// need a valid mode
938938
return -{{{ cDefs.EINVAL }}};
939939
}
940-
var lookup = FS.lookupPath(path, { follow: true });
940+
var nofollow = !!(flags & {{{ cDefs.AT_SYMLINK_NOFOLLOW }}});
941+
var lookup = FS.lookupPath(path, { follow: !nofollow });
941942
var node = lookup.node;
942943
if (!node) {
943944
return -{{{ cDefs.ENOENT }}};

0 commit comments

Comments
 (0)