aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Grunau <janne-ffmpeg@jannau.net>2011-02-09 23:23:22 +0100
committerJanne Grunau <janne-ffmpeg@jannau.net>2011-02-10 21:37:31 +0100
commit493aa30adf88baf5bc734072592a22db586f0cfb (patch)
treea8aa73930792792eccd2e29195a05f5473101a75
parent4a72765a1c94b05bd3053b1f34f8457a3b71d714 (diff)
downloadffmpeg-493aa30adf88baf5bc734072592a22db586f0cfb.tar.gz
dvbsubdec: check against buffer overreads
Signed-off-by: Janne Grunau <janne-ffmpeg@jannau.net>
-rw-r--r--libavcodec/dvbsubdec.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 401144f902..457371361c 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1423,13 +1423,15 @@ static int dvbsub_decode(AVCodecContext *avctx,
#endif
- if (buf_size <= 2 || *buf != 0x0f)
+ if (buf_size <= 6 || *buf != 0x0f) {
+ av_dlog(avctx, "incomplete or broken packet");
return -1;
+ }
p = buf;
p_end = buf + buf_size;
- while (p < p_end && *p == 0x0f) {
+ while (p_end - p >= 6 && *p == 0x0f) {
p += 1;
segment_type = *p++;
page_id = AV_RB16(p);
@@ -1437,6 +1439,11 @@ static int dvbsub_decode(AVCodecContext *avctx,
segment_length = AV_RB16(p);
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 ||
ctx->composition_id == -1 || ctx->ancillary_id == -1) {
switch (segment_type) {