aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-04-28 22:50:48 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-06-05 02:40:30 +0200
commit2fc7e5c1b553d9644ef003c15f89c17487824603 (patch)
tree0ed8aeb3c1fb50d6c42c2a3aeae96b39e277c0fd /libavformat
parent68dcb46205c79002bff4daf01b81641423776eda (diff)
downloadffmpeg-2fc7e5c1b553d9644ef003c15f89c17487824603.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>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/ffmdec.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 257319bd06..83929fe8c3 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -27,6 +27,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"
@@ -377,6 +378,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);
@@ -569,6 +575,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);