From bfdbbbf8b476c810ac9d5c47a7fa6f7cc8904a55 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 8 Sep 2015 22:53:06 +0200 Subject: Fix panic on absolute symlink --- cryptfs/cryptfs_names.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cryptfs') diff --git a/cryptfs/cryptfs_names.go b/cryptfs/cryptfs_names.go index 3dfcae9..c4f2a36 100644 --- a/cryptfs/cryptfs_names.go +++ b/cryptfs/cryptfs_names.go @@ -52,7 +52,6 @@ func (be *CryptFS) encryptName(plainName string) string { cbc.CryptBlocks(bin, bin) cipherName64 := base64.URLEncoding.EncodeToString(bin) - return cipherName64 } @@ -70,6 +69,12 @@ func (be *CryptFS) translatePath(path string, op bool) (string, error) { var translatedParts []string parts := strings.Split(path, "/") for _, part := range parts { + if part == "" { + // This happens on "/foo/bar/" on the front and on the end. + // Don't panic. + translatedParts = append(translatedParts, "") + continue + } var newPart string if op == ENCRYPT { newPart = be.encryptName(part) -- cgit v1.2.3