forked from TrueCloudLab/rclone
crypt: try not to return "unexpected EOF" error
Before this change the code wasn't taking into account the error io.ErrUnexpectedEOF that io.ReadFull can return properly. Sometimes that error was being returned instead of a more specific and useful error. To fix this, io.ReadFull was replaced with the simpler readers.ReadFill which is much easier to use correctly.
This commit is contained in:
parent
07c4d95f38
commit
d5afcf9e34
2 changed files with 12 additions and 13 deletions
|
@ -1495,8 +1495,10 @@ func TestDecrypterRead(t *testing.T) {
|
|||
case i == fileHeaderSize:
|
||||
// This would normally produce an error *except* on the first block
|
||||
expectedErr = nil
|
||||
case i <= fileHeaderSize+blockHeaderSize:
|
||||
expectedErr = ErrorEncryptedFileBadHeader
|
||||
default:
|
||||
expectedErr = io.ErrUnexpectedEOF
|
||||
expectedErr = ErrorEncryptedBadBlock
|
||||
}
|
||||
if expectedErr != nil {
|
||||
assert.EqualError(t, err, expectedErr.Error(), what)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue