1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-04 01:23:24 +00:00

crypt: Fix obfuscate filename encryption method

Fix issue #1315 where filenames calculated with a base distance of zero
(ie the characters add up to 0(mod 256) aren't de-obfuscated on reading.
This was due to overloading of "0" to also mean "invalid UTF8; no rotation",
so we remove that double meaning
This commit is contained in:
Stephen Harris
2017-04-14 08:30:18 -04:00
committed by Nick Craig-Wood
parent bc25190fc7
commit e1647a5a08
2 changed files with 5 additions and 4 deletions

View File

@@ -298,9 +298,9 @@ func (c *cipher) obfuscateSegment(plaintext string) string {
}
// If the string isn't valid UTF8 then don't rotate; just
// prepend a 0.
// prepend a !.
if !utf8.ValidString(plaintext) {
return "0." + plaintext
return "!." + plaintext
}
// Calculate a simple rotation based on the filename and
@@ -388,7 +388,7 @@ func (c *cipher) deobfuscateSegment(ciphertext string) (string, error) {
return "", ErrorNotAnEncryptedFile
} // No .
num := ciphertext[:pos]
if num == "0" {
if num == "!" {
// No rotation; probably original was not valid unicode
return ciphertext[pos+1:], nil
}