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 --- internal/ctlsock/sanitize_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 internal/ctlsock/sanitize_test.go (limited to 'internal/ctlsock/sanitize_test.go') diff --git a/internal/ctlsock/sanitize_test.go b/internal/ctlsock/sanitize_test.go new file mode 100644 index 0000000..dfcb62c --- /dev/null +++ b/internal/ctlsock/sanitize_test.go @@ -0,0 +1,25 @@ +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]) + } + } +} -- cgit v1.2.3