From patchwork Sun Sep 3 10:23:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4964 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp2148923jao; Sun, 3 Sep 2017 03:23:28 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4JVOy/61y5F02TVRujrCcoc8FBGTw9/gdB2DmqDhCZqln1GaOLfXqw3LnF+zHl8ddZyjtw X-Received: by 10.28.131.139 with SMTP id f133mr450088wmd.73.1504434208413; Sun, 03 Sep 2017 03:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504434208; cv=none; d=google.com; s=arc-20160816; b=ogYGqJcJcp2+m/r2CNjhza/+bHzFpKRE714CHQ+Tokh9qW7PAW2EDB8nbxbLS//xoh 3r93n08s1qvePX/aXEk5Izfyje8JgNb/FBHDPRn6XKj7mOsQk+rzy3OADThmrMfqpg5N /xyG3591MaU7nzk6Ybj/UzMCfYQpmtvSlLiyCMFgX0w9z9M6amWuTEGooWLJxABuHoTU PKDoVzvwYnI6GEwryzPcOBpVuv5TX0nyJK6vbn8Qk7j1fJTry3p2kQVpIK58gPKXgM47 JWaXcResKMNZ9xDsNAxji0Fj6x1fmX6ShIb7UVhgJaniXZPJVLsIjh81EdM1ZWMV/Jh+ fVUQ== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=YakWUQ3DxRzHFNEgo0pM719ZSH/1KUrvLZLjE6eS+hs=; b=Jrx73hIVdcHg/rNjxEwX/PZRuk605ym3zTnDsPM8HtWWvsbaysJs8U0Z8Cz2ugjSi1 XKziSZWuhATAKg1QvFR5jNcXFYrftvZ0NtdkretkSb8TmYCQaBzrkK58LpFU0D/f4bqv +etHEWOljFXw1/SYWOPxG0zoDgmoxsvl+GQjZslnKQQqxWy8F3AgbfYIwdhMmMIZUdFA QV8/B1SvFoHbBTjjhrPq0VgwQUdKD0Qb0ORC1gnNuu9Qxck+am5El7r3m8iZbbZ4dG7d w27dZUyRMbSSP9IYWDsuYgxXwFr+IqT/PLm0rpbM9awlC/VabW9vfewhdCixG3ABWMPE CuTg== 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 i145si3139362wmf.244.2017.09.03.03.23.27; Sun, 03 Sep 2017 03:23:28 -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 7D1E4689C08; Sun, 3 Sep 2017 13:23:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe01-1.mx.upcmail.net (vie01a-qmta-pe01-1.mx.upcmail.net [62.179.121.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 59F71689BB3 for ; Sun, 3 Sep 2017 13:23:18 +0300 (EEST) Received: from [172.31.218.52] (helo=vie01a-dmta-pe05-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1doS3k-0001D1-00 for ffmpeg-devel@ffmpeg.org; Sun, 03 Sep 2017 12:23:20 +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 1doS3d-0005v1-OP for ffmpeg-devel@ffmpeg.org; Sun, 03 Sep 2017 12:23:13 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 4yP51w0140S5wYM01yP6rU; Sun, 03 Sep 2017 12:23:06 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 3 Sep 2017 12:23:05 +0200 Message-Id: <20170903102305.8119-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 Subject: [FFmpeg-devel] [PATCH] avcodec/snowdec: Check ld/cbd/crd 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" Fixes: Timeout Fixes: 3142/clusterfuzz-testcase-5007853163118592 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/snowdec.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index b74c468ce3..7e07857a44 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -183,13 +183,24 @@ static int decode_q_branch(SnowContext *s, int level, int x, int y){ int my_context= av_log2(2*FFABS(left->my - top->my)) + 0*av_log2(2*FFABS(tr->my - top->my)); type= get_rac(&s->c, &s->block_state[1 + left->type + top->type]) ? BLOCK_INTRA : 0; - if(type){ + int ld, cbd, crd; pred_mv(s, &mx, &my, 0, left, top, tr); - l += get_symbol(&s->c, &s->block_state[32], 1); + ld = get_symbol(&s->c, &s->block_state[32], 1); + if (ld < -255 || ld > 255) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid ld %d\n", ld); + return AVERROR_INVALIDDATA; + } + l += ld; if (s->nb_planes > 2) { - cb+= get_symbol(&s->c, &s->block_state[64], 1); - cr+= get_symbol(&s->c, &s->block_state[96], 1); + cbd = get_symbol(&s->c, &s->block_state[64], 1); + crd = get_symbol(&s->c, &s->block_state[96], 1); + if (cbd < -255 || cbd > 255 || crd < -255 || crd > 255) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid cbd %d, crd %d\n", cbd, crd); + return AVERROR_INVALIDDATA; + } + cb += cbd; + cr += crd; } }else{ if(s->ref_frames > 1)