Fix a bunch of scanning / tagging bugs (#3154)

* Fix possible infinite loop/stack overflow with weird/broken zip files
* Fix path length calculation using bytes instead of characters (runes)
* Fix bug where oshash gets buffers with size not actually multiple of 8
* Add oshash tests

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
alexandra-3
2022-12-01 15:48:04 +10:00
committed by GitHub
parent e614ca8d26
commit 87cea80e7b
5 changed files with 125 additions and 82 deletions

View File

@@ -125,7 +125,12 @@ func walkDir(f FS, path string, d fs.DirEntry, walkDirFn fs.WalkDirFunc) error {
}
for _, d1 := range dirs {
path1 := filepath.Join(path, d1.Name())
name := d1.Name()
// Prevent infinite loops; this can happen with certain FS implementations (e.g. ZipFS).
if name == "" || name == "." {
continue
}
path1 := filepath.Join(path, name)
if err := walkDir(f, path1, d1, walkDirFn); err != nil {
if errors.Is(err, fs.SkipDir) {
break