mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 18:38:15 +01:00
Throw error if incoming attachment has mismatched attachment size
This commit is contained in:
@@ -1216,7 +1216,7 @@ MessageReceiver.prototype.extend({
|
||||
},
|
||||
async downloadAttachment(attachment) {
|
||||
const encrypted = await this.server.getAttachment(attachment.id);
|
||||
const { key, digest } = attachment;
|
||||
const { key, digest, size } = attachment;
|
||||
|
||||
const data = await textsecure.crypto.decryptAttachment(
|
||||
encrypted,
|
||||
@@ -1224,6 +1224,14 @@ MessageReceiver.prototype.extend({
|
||||
window.Signal.Crypto.base64ToArrayBuffer(digest)
|
||||
);
|
||||
|
||||
if (!size || size !== data.byteLength) {
|
||||
throw new Error(
|
||||
`downloadAttachment: Size ${size} did not match downloaded attachment size ${
|
||||
data.byteLength
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
..._.omit(attachment, 'digest', 'key'),
|
||||
data,
|
||||
|
||||
Reference in New Issue
Block a user