From 2758c75cae2896b7f1327fe00f60a1c017c0e0d1 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 10 Dec 2016 12:59:54 +0100 Subject: ctlsock: sanitize paths before passing them to the backend You used to be able to crash gocryptfs by passing "/foo" of "foo/" to the ctlsock. Fixes https://github.com/rfjakob/gocryptfs/issues/66 --- tests/defaults/main_test.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go index 1ad5f55..089f940 100644 --- a/tests/defaults/main_test.go +++ b/tests/defaults/main_test.go @@ -57,6 +57,13 @@ func TestCtlSock(t *testing.T) { if response.ErrNo != int32(syscall.ENOENT) || response.Result != "" { t.Errorf("incorrect error handling: %+v", response) } + // Strange paths should not cause a crash + crashers := []string{"/foo", "foo/", "/foo/", ".", "/////", "/../../."} + for _, c := range crashers { + req.EncryptPath = c + // QueryCtlSock calls t.Fatal if it gets EOF when gocryptfs panics + test_helpers.QueryCtlSock(t, sock, req) + } } // In gocryptfs before v1.2, the file header was only read once for each -- cgit v1.2.3