Browse code

lavc/mjpeg2jpeg: Check for jpeg file header.

Carl Eugen Hoyos authored on 2016/01/13 00:13:27
Showing 1 changed files
... ...
@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "libavutil/error.h"
30 30
 #include "libavutil/mem.h"
31
+#include "libavutil/intreadwrite.h"
31 32
 
32 33
 #include "avcodec.h"
33 34
 #include "jpegtables.h"
... ...
@@ -88,6 +89,10 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
88 88
         av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
89 89
         return AVERROR_INVALIDDATA;
90 90
     }
91
+    if (AV_RB16(buf) != 0xffd8) {
92
+        av_log(avctx, AV_LOG_ERROR, "input is not MJPEG\n");
93
+        return AVERROR_INVALIDDATA;
94
+    }
91 95
     if (memcmp("AVI1", buf + 6, 4)) {
92 96
         av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
93 97
         return AVERROR_INVALIDDATA;