From patchwork Thu Aug 17 22:17:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4733 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp85850vsu; Thu, 17 Aug 2017 15:18:08 -0700 (PDT) X-Received: by 10.28.139.130 with SMTP id n124mr242734wmd.168.1503008288082; Thu, 17 Aug 2017 15:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503008288; cv=none; d=google.com; s=arc-20160816; b=uIksp5U7+OEJtOd1xiC9zWBnZBGFrDEqHs6y/EPneeqAlDIm3slDkhJEOWCKYCBHr9 o8rZTMGDdabq05Z72okaqbiqB9GVGLi0TNOE+LHLqlUH9jmQu/r/wWdOMKiw/M3IGe/b zg3bKbIddfYJhdurLei/C00O0dMFx5va00om+rrB+Km7oWuvrFHh7Ff5djOQ73KIUhFG nksAyBYn25scwri/pIayadXqzGKnvdaBcqqndRwesU2mLLIUoCZrfiD+FTAEf7ch+1RZ I+fH/XuWNRhf6IpFF7plJxPU7cFKAXIMSTLw3bOVsKvY0+MyzZZRvLCCF9VEdG9OZLKs odkg== 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=k5yO3L/Ofv9JP7PQbvHZVB24RxiIk4jBrY/tw32PoFQ=; b=egUMkbAJWLBvgfCI2tqJrcioK+eyO18pYumG3vPFG4heL5GgOIevwhzAok4DZSgcVk 7baRHZQtZ3yasCGCDjxgBV0E/TgP/9gZbkYKeC9Iqf0lUvjt6yqsbrorWcz4GRWMKItk XvJdGHNf1YvXbKVSZQYF/f04uOLvClwq8HuDJCXkh4yKqp5AT+qDMENcUErZU61mt8iN 0qD+S9XYk86MNy6ZKN7Y7uZhkAy/uUB9T95t/6vBj7elecWXwKv1kaCyNAp03gTCEG4/ CkpR9vM2PtMv5rA92b5D84DUUlZ4xSGt38ZJdElJEnYpI7J5Rm8TqdS4Mwofh0qVtzCa WH1w== 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 y197si24612wmc.123.2017.08.17.15.18.07; Thu, 17 Aug 2017 15:18:08 -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 3AE156897EE; Fri, 18 Aug 2017 01:17:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-3.mx.upcmail.net (unknown [62.179.121.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC267680A18 for ; Fri, 18 Aug 2017 01:17:47 +0300 (EEST) Received: from [172.31.218.33] (helo=vie01a-dmta-pe01-3.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1diT6v-0001aF-6s for ffmpeg-devel@ffmpeg.org; Fri, 18 Aug 2017 00:17:53 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1diT6p-0003ns-Us for ffmpeg-devel@ffmpeg.org; Fri, 18 Aug 2017 00:17:47 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id yNHe1v02B0S5wYM01NHfnL; Fri, 18 Aug 2017 00:17:39 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 18 Aug 2017 00:17:35 +0200 Message-Id: <20170817221735.24154-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817221735.24154-1-michael@niedermayer.cc> References: <20170817221735.24154-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/cngdec: Check skip_samples 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" Without this its possible to make the new decode API decode billions of samples out of a empty input and never return to the caller before all samples have been created and discarded. Fixes: Timeout Fixes: 2992/clusterfuzz-testcase-6649611793989632 Signed-off-by: Michael Niedermayer --- libavcodec/cngdec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index 34f881448d..1e884f3c33 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "libavutil/ffmath.h" +#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "celp_filters.h" #include "internal.h" @@ -120,6 +121,11 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data, } } + if (avctx->internal->skip_samples > 10 * avctx->frame_size) { + avctx->internal->skip_samples = 0; + return AVERROR_INVALIDDATA; + } + if (p->inited) { p->energy = p->energy / 2 + p->target_energy / 2; for (i = 0; i < p->order; i++)