repository: reject key and config files that are too short (#21977)

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This commit is contained in:
Arpit Jain authored and GitHub committed 2026-07-22 20:38:07 +00:00
1 parent d4088aa09b
commit 8baffc4027
4 files changed
+65

No files matched your search

+4
View File
@@ -198,6 +198,10 @@ func (r *Repository) LoadUnpacked(ctx context.Context, t restic.FileType, id res
return nil, err
}
if len(buf) < crypto.CiphertextLength(0) {
return nil, fmt.Errorf("invalid data in %v file, too short", t)
}
nonce, ciphertext := buf[:r.key.NonceSize()], buf[r.key.NonceSize():]
plaintext, err := r.key.Open(ciphertext[:0], nonce, ciphertext, nil)
if err != nil {