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
This commit is contained in:
Jakob Unterwurzacher 2015-09-16 18:43:07 +02:00
parent 3be2dfdf9d
commit 3a2610a141

View File

@ -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)