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) {
|
async downloadAttachment(attachment) {
|
||||||
const encrypted = await this.server.getAttachment(attachment.id);
|
const encrypted = await this.server.getAttachment(attachment.id);
|
||||||
const { key, digest } = attachment;
|
const { key, digest, size } = attachment;
|
||||||
|
|
||||||
const data = await textsecure.crypto.decryptAttachment(
|
const data = await textsecure.crypto.decryptAttachment(
|
||||||
encrypted,
|
encrypted,
|
||||||
|
@ -1224,6 +1224,14 @@ MessageReceiver.prototype.extend({
|
||||||
window.Signal.Crypto.base64ToArrayBuffer(digest)
|
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 {
|
return {
|
||||||
..._.omit(attachment, 'digest', 'key'),
|
..._.omit(attachment, 'digest', 'key'),
|
||||||
data,
|
data,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue