Skip to content

Commit 4521055

Browse files
committed
Don't follow symlinks when checking for a mountpoint in rmdir
1 parent 1fd538b commit 4521055

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/php-wasm/universal/src/lib/fs-helpers.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,13 @@ export class FSHelpers {
139139
* To prevent the recursive option from removing internal files before
140140
* failing to remove the mount point, we need to check if the path is a
141141
* mount point and throw an error early.
142+
*
143+
* Because a mountpoint can be a symlink, we should not follow it.
144+
* Otherwise, a mounted sylink would point to the symlinked path,
145+
* instead of the mountpoint.
142146
*/
143-
const mountPoint = FS.lookupPath(path).node.mount;
144-
if (mountPoint.mountpoint === path) {
147+
const mountPoint = FS.lookupPath(path, { follow: false });
148+
if (mountPoint?.node.mount.mountpoint === path) {
145149
throw new ErrnoError(10);
146150
}
147151

0 commit comments

Comments
 (0)