diff options
author | Martijn van Beurden <mvanb1@gmail.com> | 2022-06-23 19:50:30 +0200 |
---|---|---|
committer | Martijn van Beurden <mvanb1@gmail.com> | 2022-06-26 07:42:18 +0200 |
commit | c94b4f8fbd232af27b87c26cef146c52053909cc (patch) | |
tree | 2f2081380b48f3c71b1126f07595ca94aad9fdb5 /src | |
parent | f0f9deb5b2a7823264c7353e835be0591234ebc7 (diff) | |
download | flac-c94b4f8fbd232af27b87c26cef146c52053909cc.tar.gz |
Increase max bitreader size to max metadata block size
This fixes https://github.com/xiph/flac/issues/370
Diffstat (limited to 'src')
-rw-r--r-- | src/libFLAC/bitwriter.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libFLAC/bitwriter.c b/src/libFLAC/bitwriter.c index a7f3b3d4..82c72e27 100644 --- a/src/libFLAC/bitwriter.c +++ b/src/libFLAC/bitwriter.c @@ -118,9 +118,11 @@ FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, uint32_t bits_to_add) if(bw->capacity >= new_capacity) return true; - if(new_capacity * sizeof(bwword) > FLAC__MAX_BLOCK_SIZE * FLAC__MAX_CHANNELS * (FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE + FLAC__MAX_EXTRA_RESIDUAL_BPS) / 8) - /* Requested new capacity is larger than the largest sane framesize. - * That means something went very wrong somewhere. To prevent chrashing, give up */ + if(new_capacity * sizeof(bwword) > (1u << FLAC__STREAM_METADATA_LENGTH_LEN)) + /* Requested new capacity is larger than the largest possible metadata block, + * which is also larger than the largest sane framesize. That means something + * went very wrong somewhere and previous checks failed. + * To prevent chrashing, give up */ return false; /* round up capacity increase to the nearest FLAC__BITWRITER_DEFAULT_INCREMENT */ |