internal/repository: Fix LoadBlob + fuzz test

When given a buf that is big enough for a compressed blob but not its
decompressed contents, the copy at the end of LoadBlob would skip the
last part of the contents.

Fixes #3783.
This commit is contained in:
greatroar
2022-06-06 16:26:38 +02:00
parent b7c990871f
commit c9557b2822
4 changed files with 50 additions and 1 deletions

View File

@@ -303,8 +303,9 @@ func (r *Repository) LoadBlob(ctx context.Context, t restic.BlobType, id restic.
return plaintext, nil
}
// move decrypted data to the start of the buffer
buf = buf[:len(plaintext)]
copy(buf, plaintext)
return buf[:len(plaintext)], nil
return buf, nil
}
if lastError != nil {