1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

h264: check buffer size before accessing it

Fixes invalid reads.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable@libav.org
This commit is contained in:
Anton Khirnov 2013-11-15 10:15:24 +01:00
parent 1f3e56b6dc
commit f0259a587e

View File

@ -4554,7 +4554,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
h->workaround_bugs |= FF_BUG_TRUNCATED; h->workaround_bugs |= FF_BUG_TRUNCATED;
if (!(h->workaround_bugs & FF_BUG_TRUNCATED)) if (!(h->workaround_bugs & FF_BUG_TRUNCATED))
while (ptr[dst_length - 1] == 0 && dst_length > 0) while (dst_length > 0 && ptr[dst_length - 1] == 0)
dst_length--; dst_length--;
bit_length = !dst_length ? 0 bit_length = !dst_length ? 0
: (8 * dst_length - : (8 * dst_length -