aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-09-16 18:43:07 +0200
committerJakob Unterwurzacher2015-09-16 18:43:07 +0200
commit3a2610a141b3afb96050b8dc4f7262939d563133 (patch)
treef4553197a9fd83bc42359a064c93e0b557178e5b
parent3be2dfdf9dbb6d57105217933fb3ac80d7959202 (diff)
symlink encryption: pass ".." and "." through unchanged
This fixes relative symlinks: $ tar xf linux-4.2.tar.gz tar: linux-4.2/tools/testing/selftests/powerpc/vphn/vphn.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/vphn/vphn.c: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/stringloops/memcmp_64.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/primitives/word-at-a-time.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/primitives/asm/asm-compat.h: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/memcpy_power7.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/memcpy_64.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/copyuser_power7.S: Cannot utime: No such file or directory tar: linux-4.2/tools/testing/selftests/powerpc/copyloops/copyuser_64.S: Cannot utime: No such file or directory tar: linux-4.2/arch/powerpc/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/mips/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/metag/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/arm64/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: linux-4.2/arch/arm/boot/dts/include/dt-bindings: Cannot utime: No such file or directory tar: Exiting with failure status due to previous errors
-rw-r--r--cryptfs/cryptfs_names.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cryptfs/cryptfs_names.go b/cryptfs/cryptfs_names.go
index c4f2a36..f694fa5 100644
--- a/cryptfs/cryptfs_names.go
+++ b/cryptfs/cryptfs_names.go
@@ -19,6 +19,12 @@ const (
// DecryptName - decrypt filename
func (be *CryptFS) decryptName(cipherName string) (string, error) {
+ // Make sure relative symlinks still work after encryption
+ // by passing these trough unchanged
+ if cipherName == "." || cipherName == ".." {
+ return cipherName, nil
+ }
+
bin, err := base64.URLEncoding.DecodeString(cipherName)
if err != nil {
return "", err
@@ -44,6 +50,12 @@ func (be *CryptFS) decryptName(cipherName string) (string, error) {
// EncryptName - encrypt filename
func (be *CryptFS) encryptName(plainName string) string {
+ // Make sure relative symlinks still work after encryption
+ // by passing these trough unchanged
+ if plainName == "." || plainName == ".." {
+ return plainName
+ }
+
bin := []byte(plainName)
bin = be.pad16(bin)