]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/sierravmd.c
sierravmd: limit packetsize to the amount that could be read.
[ffmpeg] / libavformat / sierravmd.c
index e1367c29ae1407b64e145f43d385eb8b9b2771f8..f614e51b5c9a5da3bcbffa0a3b5c4a71e889da88 100644 (file)
@@ -29,6 +29,8 @@
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "internal.h"
+#include "avio_internal.h"
 
 #define VMD_HEADER_SIZE 0x0330
 #define BYTES_PER_FRAME_RECORD 16
@@ -107,7 +109,7 @@ static int vmd_read_header(AVFormatContext *s,
     vst = avformat_new_stream(s, NULL);
     if (!vst)
         return AVERROR(ENOMEM);
-    av_set_pts_info(vst, 33, 1, 10);
+    avpriv_set_pts_info(vst, 33, 1, 10);
     vmd->video_stream_index = vst->index;
     vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     vst->codec->codec_id = vmd->is_indeo3 ? CODEC_ID_INDEO3 : CODEC_ID_VMDVIDEO;
@@ -148,8 +150,8 @@ static int vmd_read_header(AVFormatContext *s,
         num = st->codec->block_align;
         den = st->codec->sample_rate * st->codec->channels;
         av_reduce(&den, &num, den, num, (1UL<<31)-1);
-        av_set_pts_info(vst, 33, num, den);
-        av_set_pts_info(st, 33, num, den);
+        avpriv_set_pts_info(vst, 33, num, den);
+        avpriv_set_pts_info(st, 33, num, den);
     }
 
     toc_offset = AV_RL32(&vmd->vmd_header[812]);
@@ -245,6 +247,8 @@ static int vmd_read_packet(AVFormatContext *s,
     /* position the stream (will probably be there already) */
     avio_seek(pb, frame->frame_offset, SEEK_SET);
 
+    if(ffio_limit(pb, frame->frame_size) != frame->frame_size)
+        return AVERROR(EIO);
     if (av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD))
         return AVERROR(ENOMEM);
     pkt->pos= avio_tell(pb);