mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
fs: fix cp handle existing symlinks
PR-URL: https://github.com/nodejs/node/pull/58476 Fixes: https://github.com/nodejs/node/issues/58468 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
This commit is contained in:
1 parent
d2931e50e3
commit
996fdb05ab
2 files changed
+23
-2
No files matched your search
@@ -54,6 +54,7 @@ const {
|
||||
resolve,
|
||||
sep,
|
||||
} = require('path');
|
||||
const fsBinding = internalBinding('fs');
|
||||
|
||||
async function cpFn(src, dest, opts) {
|
||||
// Warn about using preserveTimestamps on 32-bit node
|
||||
@@ -344,7 +345,10 @@ async function onLink(destStat, src, dest, opts) {
|
||||
if (!isAbsolute(resolvedDest)) {
|
||||
resolvedDest = resolve(dirname(dest), resolvedDest);
|
||||
}
|
||||
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
|
||||
const srcIsDir = fsBinding.internalModuleStat(src) === 1;
|
||||
|
||||
if (srcIsDir && isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||||
throw new ERR_FS_CP_EINVAL({
|
||||
message: `cannot copy ${resolvedSrc} to a subdirectory of self ` +
|
||||
`${resolvedDest}`,
|
||||
|
||||
Reference in new issue
Block a user