From e49b671dcf36bcf8959719d3db5f7d4501f21b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 23 Jun 2022 19:23:52 +0200 Subject: [PATCH] kernel/vfs: lstat a symlinked dir with a trailing slash should traverse golang's TestSymlinkWithTrailingSlash exhibits the bug. Change-Id: I7e16bad9857e9be042fc215a587c861bc4eef716 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5395 Reviewed-by: waddlesplash Tested-by: Commit checker robot --- src/system/kernel/fs/vfs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 938507c0bd..c99418093b 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2179,7 +2179,9 @@ vnode_path_to_vnode(struct vnode* vnode, char* path, bool traverseLeafLink, for (nextPath = path + 1; *nextPath != '\0' && *nextPath != '/'; nextPath++); + bool directoryFound = false; if (*nextPath == '/') { + directoryFound = true; *nextPath = '\0'; do nextPath++; @@ -2226,7 +2228,7 @@ vnode_path_to_vnode(struct vnode* vnode, char* path, bool traverseLeafLink, // If the new node is a symbolic link, resolve it (if we've been told // to do it) if (S_ISLNK(nextVnode->Type()) - && (traverseLeafLink || nextPath[0] != '\0')) { + && (traverseLeafLink || directoryFound)) { size_t bufferSize; char* buffer;