Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in onSymlink #1027

Open
znewsham opened this issue Nov 15, 2023 · 1 comment
Open

Bug in onSymlink #1027

znewsham opened this issue Nov 15, 2023 · 1 comment
Assignees

Comments

@znewsham
Copy link

There is a bug when copying a directory containing a symlink onto itself (e.g., if you were making an rsync type utility):

If options.dereference is not set, then resolvedSrc and resolvedDest will always be equal - since they are the value of the symlink.

        if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
          return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`))
        }

this code needs to be changed to

if (options.dereference && stat.isSrcSubdir(resolvedSrc, resolvedDest)) {

Probably a similar change is required here:

if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
@RyanZim
Copy link
Collaborator

RyanZim commented Nov 20, 2023

Confirmed bug; but we need something more complicated than your proposed fix. We can't simply ignore these checks when we're not dereferencing; just one example case:

it('should error when resolved dest path is a subdir of resolved src path', done => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants