fix: reset position before demanding new data for frame decryption

This commit is contained in:
Samuel 2025-01-19 18:56:43 +01:00
parent 8ff12e49bb
commit 6bb11e60b7
2 changed files with 3 additions and 2 deletions

View file

@ -513,8 +513,6 @@ impl BackupDecryptor {
Err(e) => return Err(e), Err(e) => return Err(e),
}; };
// if we got to an attachment, but there we demand more data, it will be faulty, because we try to decrypt the frame although we would need
// to decrypt the attachment
match decrypt_frame( match decrypt_frame(
&mut self.reader, &mut self.reader,
hmac, hmac,
@ -524,6 +522,8 @@ impl BackupDecryptor {
frame_length, frame_length,
) { ) {
Ok(None) => { Ok(None) => {
// here we have to reset as well because the hmac depends on the length decryption which should therefore happen next time on the correct bits
self.reader.set_position(initial_reader_position);
return Ok(true); return Ok(true);
} }
Ok(Some(backup_frame)) => { Ok(Some(backup_frame)) => {

View file

@ -133,6 +133,7 @@ const App: Component = () => {
<input <input
type="file" type="file"
id="backup-input" id="backup-input"
accept=".backup"
onChange={(event) => { onChange={(event) => {
setBackupFile(event.currentTarget.files?.[0]); setBackupFile(event.currentTarget.files?.[0]);
}} }}