Commit 1a089285 authored by Janne Grunau's avatar Janne Grunau Committed by Michael Niedermayer

dvbsubdec: check against buffer overreads

Signed-off-by: 's avatarJanne Grunau <janne-ffmpeg@jannau.net>
(cherry picked from commit 493aa30a)
parent 20708223
...@@ -1423,13 +1423,15 @@ static int dvbsub_decode(AVCodecContext *avctx, ...@@ -1423,13 +1423,15 @@ static int dvbsub_decode(AVCodecContext *avctx,
#endif #endif
if (buf_size <= 2 || *buf != 0x0f) if (buf_size <= 6 || *buf != 0x0f) {
av_dlog(avctx, "incomplete or broken packet");
return -1; return -1;
}
p = buf; p = buf;
p_end = buf + buf_size; p_end = buf + buf_size;
while (p < p_end && *p == 0x0f) { while (p_end - p >= 6 && *p == 0x0f) {
p += 1; p += 1;
segment_type = *p++; segment_type = *p++;
page_id = AV_RB16(p); page_id = AV_RB16(p);
...@@ -1437,6 +1439,11 @@ static int dvbsub_decode(AVCodecContext *avctx, ...@@ -1437,6 +1439,11 @@ static int dvbsub_decode(AVCodecContext *avctx,
segment_length = AV_RB16(p); segment_length = AV_RB16(p);
p += 2; p += 2;
if (p_end - p < segment_length) {
av_dlog(avctx, "incomplete or broken packet");
return -1;
}
if (page_id == ctx->composition_id || page_id == ctx->ancillary_id || if (page_id == ctx->composition_id || page_id == ctx->ancillary_id ||
ctx->composition_id == -1 || ctx->ancillary_id == -1) { ctx->composition_id == -1 || ctx->ancillary_id == -1) {
switch (segment_type) { switch (segment_type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment