diff mbox

[FFmpeg-devel] avcodec/vp9_parser: Check the input frame sizes for being consistent

Message ID 1470054514-3633-1-git-send-email-michael@niedermayer.cc
State Accepted
Commit 77b0f3f26d33d4f46f274896e0583ad1f5936b7c
Headers show

Commit Message

Michael Niedermayer Aug. 1, 2016, 12:28 p.m. UTC
Suggested-by: BBB
Fixed-by: BBB
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/vp9_parser.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Michael Niedermayer Aug. 1, 2016, 3:21 p.m. UTC | #1
On Mon, Aug 01, 2016 at 02:28:34PM +0200, Michael Niedermayer wrote:
> Suggested-by: BBB
> Fixed-by: BBB
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vp9_parser.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

applied

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c
index 2e9235e..9900e7a 100644
--- a/libavcodec/vp9_parser.c
+++ b/libavcodec/vp9_parser.c
@@ -28,6 +28,7 @@ 
 typedef struct VP9ParseContext {
     int n_frames; // 1-8
     int size[8];
+    int marker_size;
     int64_t pts;
 } VP9ParseContext;
 
@@ -89,6 +90,21 @@  static int parse(AVCodecParserContext *ctx,
     }
 
     if (s->n_frames > 0) {
+        int i;
+        int size_sum = 0;
+
+        for (i = 0; i < s->n_frames ;i++)
+            size_sum += s->size[i];
+        size_sum += s->marker_size;
+
+        if (size_sum != size) {
+            av_log(avctx, AV_LOG_ERROR, "Inconsistent input frame sizes %d %d\n",
+                   size_sum, size);
+            s->n_frames = 0;
+        }
+    }
+
+    if (s->n_frames > 0) {
         *out_data = data;
         *out_size = s->size[--s->n_frames];
         parse_frame(ctx, *out_data, *out_size);
@@ -131,6 +147,7 @@  static int parse(AVCodecParserContext *ctx,
                     data += sz; \
                     size -= sz; \
                 } \
+                s->marker_size = size; \
                 parse_frame(ctx, *out_data, *out_size); \
                 return s->n_frames > 0 ? *out_size : full_size