diff options
author | Jakob Unterwurzacher | 2015-09-08 22:53:06 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-09-08 22:53:06 +0200 |
commit | bfdbbbf8b476c810ac9d5c47a7fa6f7cc8904a55 (patch) | |
tree | af556055fa9a6bb9b264c40368906d7b5805bf0c | |
parent | 28cdff5889927fcf8d720f13fcfe139720906988 (diff) |
Fix panic on absolute symlink
-rw-r--r-- | cryptfs/cryptfs_names.go | 7 | ||||
-rw-r--r-- | pathfs_frontend/fs.go | 1 |
2 files changed, 7 insertions, 1 deletions
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) diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go index 2f73462..0c1d879 100644 --- a/pathfs_frontend/fs.go +++ b/pathfs_frontend/fs.go @@ -134,6 +134,7 @@ func (fs *FS) Rmdir(name string, context *fuse.Context) (code fuse.Status) { func (fs *FS) Symlink(pointedTo string, linkName string, context *fuse.Context) (code fuse.Status) { // TODO symlink encryption + cryptfs.Debug.Printf("Symlink(\"%s\", \"%s\")\n", pointedTo, linkName) return fs.FileSystem.Symlink(fs.EncryptPath(pointedTo), fs.EncryptPath(linkName), context) } |