Fix an out of bounds read in _jbig2_get_next_segment()

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38451
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2023-01-01 09:43:33 +01:00
parent 52e964da69
commit d623090b32

View file

@ -348,6 +348,8 @@ _jbig2_get_next_segment (const unsigned char *p,
num_segs = p[0] >> 5;
if (num_segs == 7) {
if (p + 4 >= end)
return NULL;
num_segs = get_unaligned_be32 (p) & 0x1fffffff;
ref_seg_bytes = 4 + ((num_segs + 1)/8);
} else {