mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-11 11:40:42 +08:00
avcodec/cbs: Fix potential overflow
The number of bits in a PutBitContext must fit into an int, yet nothing guaranteed the size argument cbs_write_unit_data() uses in init_put_bits() to be in the range 0..INT_MAX / 8. This has been changed. Furthermore, the check 8 * data_size > data_bit_start that there is data beyond the initial padding when writing mpeg2 or H.264/5 slices could also overflow, so divide it by 8 to get an equivalent check without this problem. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:

committed by
Mark Thompson

parent
7c92eaace2
commit
cda3e8ca04
@@ -337,7 +337,7 @@ static int cbs_mpeg2_write_slice(CodedBitstreamContext *ctx,
|
||||
uint8_t *pos = slice->data + slice->data_bit_start / 8;
|
||||
|
||||
av_assert0(slice->data_bit_start >= 0 &&
|
||||
8 * slice->data_size > slice->data_bit_start);
|
||||
slice->data_size > slice->data_bit_start / 8);
|
||||
|
||||
if (slice->data_size * 8 + 8 > put_bits_left(pbc))
|
||||
return AVERROR(ENOSPC);
|
||||
|
Reference in New Issue
Block a user