diff options
Diffstat (limited to 'vendor/codeberg.org/gruf/go-store/util')
| -rw-r--r-- | vendor/codeberg.org/gruf/go-store/util/fs.go | 31 | ||||
| -rw-r--r-- | vendor/codeberg.org/gruf/go-store/util/sys.go | 14 | 
2 files changed, 14 insertions, 31 deletions
diff --git a/vendor/codeberg.org/gruf/go-store/util/fs.go b/vendor/codeberg.org/gruf/go-store/util/fs.go index 93b37a261..53fef7750 100644 --- a/vendor/codeberg.org/gruf/go-store/util/fs.go +++ b/vendor/codeberg.org/gruf/go-store/util/fs.go @@ -3,30 +3,10 @@ package util  import (  	"io/fs"  	"os" -	"strings" -	"syscall"  	"codeberg.org/gruf/go-fastpath"  ) -// IsDirTraversal will check if rootPlusPath is a dir traversal outside of root, -// assuming that both are cleaned and that rootPlusPath is path.Join(root, somePath) -func IsDirTraversal(root string, rootPlusPath string) bool { -	switch { -	// Root is $PWD, check for traversal out of -	case root == ".": -		return strings.HasPrefix(rootPlusPath, "../") - -	// The path MUST be prefixed by root -	case !strings.HasPrefix(rootPlusPath, root): -		return true - -	// In all other cases, check not equal -	default: -		return len(root) == len(rootPlusPath) -	} -} -  // WalkDir traverses the dir tree of the supplied path, performing the supplied walkFn on each entry  func WalkDir(pb *fastpath.Builder, path string, walkFn func(string, fs.DirEntry)) error {  	// Read supplied dir path @@ -100,14 +80,3 @@ func cleanDirs(pb *fastpath.Builder, path string) error {  	}  	return nil  } - -// RetryOnEINTR is a low-level filesystem function for retrying syscalls on O_EINTR received -func RetryOnEINTR(do func() error) error { -	for { -		err := do() -		if err == syscall.EINTR { -			continue -		} -		return err -	} -} diff --git a/vendor/codeberg.org/gruf/go-store/util/sys.go b/vendor/codeberg.org/gruf/go-store/util/sys.go new file mode 100644 index 000000000..6661029e5 --- /dev/null +++ b/vendor/codeberg.org/gruf/go-store/util/sys.go @@ -0,0 +1,14 @@ +package util + +import "syscall" + +// RetryOnEINTR is a low-level filesystem function for retrying syscalls on O_EINTR received +func RetryOnEINTR(do func() error) error { +	for { +		err := do() +		if err == syscall.EINTR { +			continue +		} +		return err +	} +}  | 
