Throw error if incoming attachment has mismatched attachment size
This commit is contained in:
parent
f5af063191
commit
7c4ba5446c
1 changed files with 9 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue