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
26 lines
408 B
Go
26 lines
408 B
Go
package ctlsock
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSanitizePath(t *testing.T) {
|
|
testCases := [][]string{
|
|
{"", ""},
|
|
{".", ""},
|
|
{"/", ""},
|
|
{"foo", "foo"},
|
|
{"/foo", "foo"},
|
|
{"foo/", "foo"},
|
|
{"/foo/", "foo"},
|
|
{"/foo/./foo", "foo/foo"},
|
|
{"./", ""},
|
|
}
|
|
for _, tc := range testCases {
|
|
res := SanitizePath(tc[0])
|
|
if res != tc[1] {
|
|
t.Errorf("%q: got %q, want %q", tc[0], res, tc[1])
|
|
}
|
|
}
|
|
}
|