X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsmjpegdec.c;h=a4e1f957ed839e3ed1bfc4818dfd9a4d9352c53e;hb=626535f6a169e2d821b969e0ea77125ba7482113;hp=c184c0d9fdc04e5cbc0dfb3df6b313125908c17d;hpb=27e30c73d722ec13e59753dea91be00859c72bf2;p=ffmpeg diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c index c184c0d9fdc..a4e1f957ed8 100644 --- a/libavformat/smjpegdec.c +++ b/libavformat/smjpegdec.c @@ -36,7 +36,7 @@ typedef struct SMJPEGContext { int video_stream_index; } SMJPEGContext; -static int smjpeg_probe(AVProbeData *p) +static int smjpeg_probe(const AVProbeData *p) { if (!memcmp(p->buf, SMJPEG_MAGIC, 8)) return AVPROBE_SCORE_MAX; @@ -51,6 +51,9 @@ static int smjpeg_read_header(AVFormatContext *s) uint32_t version, htype, hlength, duration; char *comment; + sc->audio_stream_index = + sc->video_stream_index = -1; + avio_skip(pb, 8); // magic version = avio_rb32(pb); if (version) @@ -147,6 +150,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) dtype = avio_rl32(s->pb); switch (dtype) { case SMJPEG_SNDD: + if (sc->audio_stream_index < 0) + return AVERROR_INVALIDDATA; timestamp = avio_rb32(s->pb); size = avio_rb32(s->pb); ret = av_get_packet(s->pb, pkt, size); @@ -155,6 +160,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos = pos; break; case SMJPEG_VIDD: + if (sc->video_stream_index < 0) + return AVERROR_INVALIDDATA; timestamp = avio_rb32(s->pb); size = avio_rb32(s->pb); ret = av_get_packet(s->pb, pkt, size);