From d8fb28a1c38cda0b013c617404ad4a768effb704 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 10 Nov 2016 23:51:47 +0100 Subject: ctlsock: prevent panic on invalid decrypt request --- tests/reverse/ctlsock_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests/reverse') diff --git a/tests/reverse/ctlsock_test.go b/tests/reverse/ctlsock_test.go index 0e4a29b..8a7d462 100644 --- a/tests/reverse/ctlsock_test.go +++ b/tests/reverse/ctlsock_test.go @@ -22,7 +22,8 @@ var ctlSockTestCases = [][]string{ {"gocryptfs.longname.cvRximo1ATRJVEzw_V9MZieHFlod9y2iv2Sug1kbiTE=/rBPJYAzcHWLdPj1T8kgh8A==", "longdir." + x240 + "/file"}, } -func TestCtlSockDecryptPath(t *testing.T) { +// Test DecryptPath and EncryptPath +func TestCtlSockPathOps(t *testing.T) { mnt, err := ioutil.TempDir(test_helpers.TmpDir, "reverse_mnt_") if err != nil { t.Fatal(err) @@ -50,3 +51,18 @@ func TestCtlSockDecryptPath(t *testing.T) { } } } + +// We should not panic when somebody feeds requests that make no sense +func TestCtlSockCrash(t *testing.T) { + mnt, err := ioutil.TempDir(test_helpers.TmpDir, "reverse_mnt_") + if err != nil { + t.Fatal(err) + } + sock := mnt + ".sock" + test_helpers.MountOrFatal(t, "ctlsock_reverse_test_fs", mnt, "-reverse", "-extpass", "echo test", "-ctlsock="+sock, + "-wpanic=0", "-nosyslog=0") + defer test_helpers.UnmountPanic(mnt) + // Try to crash it + req := ctlsock.RequestStruct{DecryptPath: "gocryptfs.longname.XXX_TestCtlSockCrash_XXX.name"} + test_helpers.QueryCtlSock(t, sock, req) +} -- cgit v1.2.3