1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

crypt: add --crypt-pass-bad-blocks to allow corrupted file output

This commit is contained in:
Nick Craig-Wood
2023-03-06 17:54:07 +00:00
parent d5afcf9e34
commit d0810b602a
3 changed files with 36 additions and 1 deletions

View File

@@ -1536,6 +1536,17 @@ func TestDecrypterRead(t *testing.T) {
}
file16copy[i] ^= 0xFF
}
// Test that we can corrupt a byte and read zeroes if
// passBadBlocks is set
copy(file16copy, file16)
file16copy[len(file16copy)-1] ^= 0xFF
c.passBadBlocks = true
fh, err = c.newDecrypter(io.NopCloser(bytes.NewBuffer(file16copy)))
assert.NoError(t, err)
buf, err := io.ReadAll(fh)
assert.NoError(t, err)
assert.Equal(t, make([]byte, 16), buf)
}
func TestDecrypterClose(t *testing.T) {