Add sanity check to the file walker
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jul 2016 17:54:07 +0000 (19:54 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 30 Jul 2016 17:54:07 +0000 (19:54 +0200)
As more tests now hit the virtual filesystem, add this check
to prevent any walking of the entire file system.

helpers/path.go

index 1d3419fb2d9a8ed00626c36baee33dbf402e5043..91017d51310253a0aa561aa31a9c7477c5ccccaf 100644 (file)
@@ -467,6 +467,11 @@ func FindCWD() (string, error) {
 // the file structure
 func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error {
 
+       // Sanity check
+       if len(root) < 5 {
+               return fmt.Errorf("Path to short, cannot walk the root: %s", root)
+       }
+
        // Handle the root first
        fileInfo, err := lstatIfOs(fs, root)