diff options
author | Rongjian Zhang <pd4d10@gmail.com> | 2019-11-22 14:01:21 +0800 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-12-03 23:48:08 +0100 |
commit | 0e3d774ed21375675b024f555a67773821e56a9d (patch) | |
tree | 40b8710c72e8adab75dbae5632c81a76f715667c /lib | |
parent | 3ebae6cf1b20ce104423214d75c3c84129a8f141 (diff) | |
download | android-node-v8-0e3d774ed21375675b024f555a67773821e56a9d.tar.gz android-node-v8-0e3d774ed21375675b024f555a67773821e56a9d.tar.bz2 android-node-v8-0e3d774ed21375675b024f555a67773821e56a9d.zip |
fs: fix existsSync for invalid symlink at win32
Fixes: https://github.com/nodejs/node/issues/30538
PR-URL: https://github.com/nodejs/node/pull/30556
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -234,7 +234,16 @@ function existsSync(path) { return false; } const ctx = { path }; - binding.access(pathModule.toNamespacedPath(path), F_OK, undefined, ctx); + const nPath = pathModule.toNamespacedPath(path); + binding.access(nPath, F_OK, undefined, ctx); + + // In case of an invalid symlink, `binding.access()` on win32 + // will **not** return an error and is therefore not enough. + // Double check with `binding.stat()`. + if (isWindows && ctx.errno === undefined) { + binding.stat(nPath, false, undefined, ctx); + } + return ctx.errno === undefined; } |