flv: Validate the packet size
[ffmpeg.git] / libavformat / flvdec.c
index 693c859..1b29740 100644 (file)
@@ -912,6 +912,12 @@ skip:
         st->codecpar->codec_id == AV_CODEC_ID_H264) {
         int type = avio_r8(s->pb);
         size--;
+
+        if (size < 0) {
+            ret = AVERROR_INVALIDDATA;
+            goto leave;
+        }
+
         if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
             // sign extension
             int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;