mirror of https://git.ffmpeg.org/ffmpeg.git
jpeg2000: check len before parsing header
Avoid overread. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
eae63e3c15
commit
fd54dd028b
|
@ -1241,9 +1241,10 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
|
||||||
if (marker == JPEG2000_EOC)
|
if (marker == JPEG2000_EOC)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (bytestream2_get_bytes_left(&s->g) < 2)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
len = bytestream2_get_be16u(&s->g);
|
len = bytestream2_get_be16u(&s->g);
|
||||||
|
if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
switch (marker) {
|
switch (marker) {
|
||||||
case JPEG2000_SIZ:
|
case JPEG2000_SIZ:
|
||||||
ret = get_siz(s);
|
ret = get_siz(s);
|
||||||
|
|
Loading…
Reference in New Issue