Check that size is number, not truthiness of size

This commit is contained in:
Scott Nonnenberg 2022-06-23 15:42:19 -07:00 committed by GitHub
parent a74070f4ed
commit 72bb01346f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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!');
}