X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libavcodec%2Fxan.c;h=bccbe24d85b7489c18f14c463abf52a882adef24;hb=52066bdb300b3a2cdef48897d0c864410b259084;hp=f11f1bf0625d50029b27d3c2100728ddb9570e98;hpb=dcb0d1193a3de3711bdb410c1fe3f70cc5143603;p=ffmpeg diff --git a/libavcodec/xan.c b/libavcodec/xan.c index f11f1bf0625..bccbe24d85b 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -33,12 +33,11 @@ #include #include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" #include "avcodec.h" #include "bytestream.h" #define BITSTREAM_READER_LE #include "get_bits.h" -// for av_memcpy_backptr -#include "libavutil/lzo.h" #define RUNTIME_GAMMA 0 @@ -360,17 +359,29 @@ static int xan_wc3_decode_frame(XanContext *s) { case 9: case 19: + if (buf_end - size_segment < 1) { + av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n"); + return AVERROR_INVALIDDATA; + } size = *size_segment++; break; case 10: case 20: + if (buf_end - size_segment < 2) { + av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n"); + return AVERROR_INVALIDDATA; + } size = AV_RB16(&size_segment[0]); size_segment += 2; break; case 11: case 21: + if (buf_end - size_segment < 3) { + av_log(s->avctx, AV_LOG_ERROR, "size_segment overread\n"); + return AVERROR_INVALIDDATA; + } size = AV_RB24(size_segment); size_segment += 3; break;