From 17ce5ac75f689f54fa00516cf2d6793bc9d5e361 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Thu, 23 Jun 2022 17:36:56 -0700 Subject: [PATCH] Check that size is number, not truthiness of size Co-authored-by: Scott Nonnenberg --- ts/textsecure/processDataMessage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/textsecure/processDataMessage.ts b/ts/textsecure/processDataMessage.ts index 721c08fe4..7fa08b8ea 100644 --- a/ts/textsecure/processDataMessage.ts +++ b/ts/textsecure/processDataMessage.ts @@ -3,6 +3,7 @@ import Long from 'long'; import { ReceiptCredentialPresentation } from '@signalapp/libsignal-client/zkgroup'; +import { isNumber } from 'lodash'; import { assert, strictAssert } from '../util/assert'; import { dropNull, shallowDropNull } from '../util/dropNull'; @@ -50,7 +51,7 @@ export function processAttachment( const hasCdnId = Long.isLong(cdnId) ? !cdnId.isZero() : Boolean(cdnId); const { contentType, digest, key, size } = attachment; - if (!size) { + if (!isNumber(size)) { throw new Error('Missing size on incoming attachment!'); }