Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

#3977 Node.js crash on Windows when no read permissions for the root #6434

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1227,8 +1227,17 @@ fs.realpathSync = function realpathSync(p, cache) {
// some known symbolic link. no need to stat again.
resolvedLink = cache[base];
} else {
var stat = fs.lstatSync(base);
if (!stat.isSymbolicLink()) {
var stat = null;
try {
stat = fs.lstatSync(base);
} catch (e) {
// Windows throws an exception if NTFS permissions are missing
if (!isWindows || e.code != 'EPERM') {
throw e;
}
}

if (stat == null || !stat.isSymbolicLink()) {
knownHard[base] = true;
if (cache) cache[base] = base;
continue;
Expand Down