From patchwork Sun Jul 15 13:13:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9731 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp1354540jad; Sun, 15 Jul 2018 06:14:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcw/yWV+C2Q1mYs2RZfPWI1urwoFI5Xgq6eSIZhv+/rpG7xQ8Hk2F/wkxb8AfifLFqYnjeP X-Received: by 2002:adf:ef03:: with SMTP id e3-v6mr9034387wro.182.1531660467561; Sun, 15 Jul 2018 06:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531660467; cv=none; d=google.com; s=arc-20160816; b=Z5oDoavuPwd89NkDPwP4OoCFKwfMIeaYG1RNPP86xPF6HNFjL14aexefqNUnXxgWJ2 aLP8g1jz4TSxp3JL14nsEokrK3t2f5QxLOJ2p65JJilup4O+/t85rKjW4oycjHYGAGwa R+KBRDLAkLgQoF9AZ+EYdff978iqP19OiRweA3Mz0EH51bLtiwUhXXeaS4SoVeM+1hTv mEaCuVMLt0GGG+fkkpxM1MDRFjzaLEk5kZcJy+790P5D2b3U01LsudQ5Cz1X1J2/w1BX lNqmj5Nt6Q1voL97LJrePliFrDdUNHJIbAc4iWUPDSeLaDAv37WASZtAPsWwQXGjzfZw xWbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=QWR9G8fOwMqnsfEqubyoib42Jf6sAyHUV72TChLw2q0=; b=OOoy2kuSPotoZw3bGKzSFltJRWrMva49Exn0NREavB1VJfYGOJcQ5867nzozAhE+hV 2RgVnsu1o6KpF2yhL0jA0m74KaD4oVWPcndXi9mTkn50gzTWQ4tsbOtu4ej3zBZdLTHt cQZpBNBBZA8NgKBC9zjijPsz3WoPPcHfnHIqks6dXV8VYCGYCOgrYpOPSteIXY7ulZWq BuA7dBgv5J3sQObcw+2D3DPy5px3sgFGvVexALf/bLmDQXKmNwhGEqtZ09Hi+9g8RTNP 1SbGbbgvjkISbKi624McP7U5ayx0S6VX8AMu3p9nWo3DTpz6QQVTKOzAvb9YCYZj6eiu lWGw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k5-v6si18897210wrq.10.2018.07.15.06.14.27; Sun, 15 Jul 2018 06:14:27 -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 0A80E68A595; Sun, 15 Jul 2018 16:14:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-2.mx.upcmail.net (vie01a-qmta-pe01-2.mx.upcmail.net [62.179.121.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8E544689957 for ; Sun, 15 Jul 2018 16:13:53 +0300 (EEST) Received: from [172.31.218.54] (helo=vie01a-dmta-pe08-3.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fegqh-0002zY-31 for ffmpeg-devel@ffmpeg.org; Sun, 15 Jul 2018 15:14:03 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe08.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fegqb-0006ki-RI for ffmpeg-devel@ffmpeg.org; Sun, 15 Jul 2018 15:13:57 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id B1Dp1y01W0S5wYM011DqSb; Sun, 15 Jul 2018 15:13:50 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 15 Jul 2018 15:13:38 +0200 Message-Id: <20180715131341.28705-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180715131341.28705-1-michael@niedermayer.cc> References: <20180715131341.28705-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/tscc: Move reget buffer to after decoding 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" reget buffer can be time consuming, theres no need to do it if failures occur Testcase: 9010/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TSCC_fuzzer-6042614817095680 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tscc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c index cb86b584c1..f891932342 100644 --- a/libavcodec/tscc.c +++ b/libavcodec/tscc.c @@ -70,9 +70,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVFrame *frame = c->frame; int ret; - if ((ret = ff_reget_buffer(avctx, frame)) < 0) - return ret; - ret = inflateReset(&c->zstream); if (ret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret); @@ -89,6 +86,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return AVERROR_UNKNOWN; } + if ((ret = ff_reget_buffer(avctx, frame)) < 0) + return ret; if (ret != Z_DATA_ERROR) { bytestream2_init(&c->gb, c->decomp_buf,