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 <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Jérôme Duval
2022-06-24 08:31:44 +00:00
committed by Adrien Destugues
parent c95c5ed821
commit e49b671dcf
+3 -1
View File
@@ -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;