mirror of
https://github.com/FiloSottile/age.git
synced 2026-09-19 14:34:21 +00:00
stream: fix NewDecryptReaderAt EOF handling (#708)
Co-authored-by: Arpit Gupta <arpitb.lgupta1@gmail.com>
This commit is contained in:
co-authored by
Arpit Gupta
parent
2313f65737
commit
b155aff565
@@ -374,7 +374,15 @@ func NewDecryptReaderAt(key []byte, src io.ReaderAt, size int64) (*DecryptReader
|
||||
finalChunkOff := finalChunkIndex * encChunkSize
|
||||
finalChunkSize := size - finalChunkOff
|
||||
finalChunk := make([]byte, finalChunkSize)
|
||||
if _, err := src.ReadAt(finalChunk, finalChunkOff); err != nil {
|
||||
nn, err := src.ReadAt(finalChunk, finalChunkOff)
|
||||
if err == io.EOF {
|
||||
if int64(nn) != finalChunkSize {
|
||||
err = io.ErrUnexpectedEOF
|
||||
} else {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read final chunk: %w", err)
|
||||
}
|
||||
nonce := nonceForChunk(finalChunkIndex)
|
||||
|
||||
Reference in New Issue
Block a user