[FFmpeg-devel,3/3] mpeg12dec: validate color transfer characteristics

Submitted by Andreas Cadhalpun on Dec. 22, 2016, 11:59 p.m.

Details

Message ID 7e14d073-7abe-03c0-d347-80f05343c4de@googlemail.com
State New
Headers show

Commit Message

Andreas Cadhalpun Dec. 22, 2016, 11:59 p.m.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/mpeg12dec.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 89aecd4de4..964f498f3b 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1473,6 +1473,10 @@  static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
             s->avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
         }
         s->avctx->color_trc       = get_bits(&s->gb, 8);
+        if (!av_color_transfer_name(s->avctx->color_trc)) {
+            av_log(s->avctx, AV_LOG_WARNING, "Invalid color transfer characteristics %d, setting to unspecified\n", s->avctx->color_trc);
+            s->avctx->color_trc = AVCOL_TRC_UNSPECIFIED;
+        }
         s->avctx->colorspace      = get_bits(&s->gb, 8);
         if (!av_color_space_name(s->avctx->colorspace)) {
             av_log(s->avctx, AV_LOG_WARNING, "Invalid color space %d, setting to unspecified\n", s->avctx->colorspace);