From patchwork Mon Aug 1 12:28:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 47 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp2681286vsd; Mon, 1 Aug 2016 05:32:20 -0700 (PDT) X-Received: by 10.194.113.9 with SMTP id iu9mr51022573wjb.118.1470054740639; Mon, 01 Aug 2016 05:32:20 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dv5si31115727wjd.150.2016.08.01.05.31.57; Mon, 01 Aug 2016 05:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91FE8689D9C; Mon, 1 Aug 2016 15:31:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E08DC689D98 for ; Mon, 1 Aug 2016 15:31:22 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1bUCNT-0000Ik-NG for ffmpeg-devel@ffmpeg.org; Mon, 01 Aug 2016 14:31:27 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id RoXS1t00A0S5wYM01oXTkh; Mon, 01 Aug 2016 14:31:27 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 1 Aug 2016 14:28:34 +0200 Message-Id: <1470054514-3633-1-git-send-email-michael@niedermayer.cc> X-Mailer: git-send-email 1.7.9.5 Subject: [FFmpeg-devel] [PATCH] avcodec/vp9_parser: Check the input frame sizes for being consistent X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Suggested-by: BBB Fixed-by: BBB Signed-off-by: Michael Niedermayer --- libavcodec/vp9_parser.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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