diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-04-28 22:50:48 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-05-01 05:00:45 +0200 |
commit | 95a8dace5cc70ad94f0820ed9fb9679276a385e9 (patch) | |
tree | 5934739d6669b5f9df32fb8bb109df7af94b9199 | |
parent | fb15a0f42af35c9b837e3766c38ce633b38782a0 (diff) | |
download | ffmpeg-95a8dace5cc70ad94f0820ed9fb9679276a385e9.tar.gz |
avformat/ffmdec: Check pix_fmt
Fixes crash
Fixes Ticket5412
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 78baa450d9939957f52d5187beb95d763d2f1f18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/ffmdec.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index b5135f18cd..4faecacd10 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -26,6 +26,7 @@ #include "libavutil/opt.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/pixdesc.h" #include "avformat.h" #include "internal.h" #include "ffm.h" @@ -365,6 +366,11 @@ static int ffm2_read_header(AVFormatContext *s) codec->height = avio_rb16(pb); codec->gop_size = avio_rb16(pb); codec->pix_fmt = avio_rb32(pb); + if (!av_pix_fmt_desc_get(codec->pix_fmt)) { + av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt); + codec->pix_fmt = AV_PIX_FMT_NONE; + goto fail; + } codec->qmin = avio_r8(pb); codec->qmax = avio_r8(pb); codec->max_qdiff = avio_r8(pb); @@ -556,6 +562,11 @@ static int ffm_read_header(AVFormatContext *s) codec->height = avio_rb16(pb); codec->gop_size = avio_rb16(pb); codec->pix_fmt = avio_rb32(pb); + if (!av_pix_fmt_desc_get(codec->pix_fmt)) { + av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", codec->pix_fmt); + codec->pix_fmt = AV_PIX_FMT_NONE; + goto fail; + } codec->qmin = avio_r8(pb); codec->qmax = avio_r8(pb); codec->max_qdiff = avio_r8(pb); |