lib/scanner: Don't scan if input path is below symlink (fixes #6090) (#6101)

This commit is contained in:
Simon Frei
2019-10-22 11:12:21 +02:00
committed by Jakob Borg
parent 8b5bd45a29
commit 72194d137c
2 changed files with 27 additions and 2 deletions

View File

@@ -322,7 +322,7 @@ func TestWalkRootSymlink(t *testing.T) {
}
defer os.RemoveAll(tmp)
link := tmp + "/link"
link := filepath.Join(tmp, "link")
dest, _ := filepath.Abs("testdata/dir1")
if err := osutil.DebugSymlinkForTestsOnly(dest, link); err != nil {
if runtime.GOOS == "windows" {
@@ -333,13 +333,33 @@ func TestWalkRootSymlink(t *testing.T) {
}
}
// Scan it
// Scan root with symlink at FS root
files := walkDir(fs.NewFilesystem(fs.FilesystemTypeBasic, link), ".", nil, nil, 0)
// Verify that we got two files
if len(files) != 2 {
t.Errorf("expected two files, not %d", len(files))
}
// Scan symlink below FS root
files = walkDir(fs.NewFilesystem(fs.FilesystemTypeBasic, tmp), "link", nil, nil, 0)
// Verify that we got the one symlink, except on windows
if runtime.GOOS == "windows" {
if len(files) != 0 {
t.Errorf("expected no files, not %d", len(files))
}
} else if len(files) != 1 {
t.Errorf("expected one file, not %d", len(files))
}
// Scan path below symlink
files = walkDir(fs.NewFilesystem(fs.FilesystemTypeBasic, tmp), filepath.Join("link", "cfile"), nil, nil, 0)
// Verify that we get nothing
if len(files) != 0 {
t.Errorf("expected no files, not %d", len(files))
}
}
func TestBlocksizeHysteresis(t *testing.T) {