2758c75cae
You used to be able to crash gocryptfs by passing "/foo" of "foo/" to the ctlsock. Fixes https://github.com/rfjakob/gocryptfs/issues/66
21 lines
409 B
Go
21 lines
409 B
Go
package ctlsock
|
|
|
|
import (
|
|
"path/filepath"
|
|
)
|
|
|
|
// SanitizePath adapts filepath.Clean for FUSE paths.
|
|
// 1) It always returns a relative path
|
|
// 2) It returns "" instead of "."
|
|
// See the TestSanitizePath testcases for examples.
|
|
func SanitizePath(path string) string {
|
|
clean := filepath.Clean(path)
|
|
if clean == "." || clean == "/" {
|
|
return ""
|
|
}
|
|
if clean[0] == '/' {
|
|
clean = clean[1:]
|
|
}
|
|
return clean
|
|
}
|