From patchwork Fri Nov 3 16:48:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5848 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp70268jah; Fri, 3 Nov 2017 09:48:48 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SoxH4p4L86LB4w1ZXQC0rUd8zAOGxxAut20dl83lWq5A8lGXa4iUnLLQJrkz9pIl1d/tne X-Received: by 10.28.134.149 with SMTP id i143mr300661wmd.79.1509727728689; Fri, 03 Nov 2017 09:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509727728; cv=none; d=google.com; s=arc-20160816; b=GS1WP5F7eyRhdFUnY9doC0HHUPE297SRqs/BxwMhh4mzq2syeOyqyhGATk/ImTKyTE ok2jFqZPPsjJIJ4rcadFRZVMTRxpxEXeQ6TpDI3MO7978T9clt+XcsJMLU24h7I0bU6D bx8IoFnPiITgAs2E7YMKXXn+i01inE5c0PYdcAJPuvyA60TBvTP+677AHeV76kuZeSfz PwIgo3TTavDF7PV9HUUWlMStv1cAJF394jxNPvIZ8BD+txFWWZAbVHQRDZodE0qTvh03 MYrwpfgV1B5o17TmucUOFR/sr4M+eXXyOYt3f96nxd3YlW7dZ+r/CYIcMm8k0FmLIG6j vO+A== 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=NT9Xxr1jdzNKoKoh1wRte99RctPUQVitnVWr/nlkOOI=; b=0OV/k55fhDaiMWMWCxvV4nYI7yOWPzXFTHLmRdjEp3dgmjWqJ8kSW4YuvGK6JliVaJ N20gPKWKr6YxOBqv2oYB5J1JCqQd4ikEJ0pfsushHpf5pXb+mga15LTIReFnZjJIXa5/ KFikE1aBoE4IXq8ElQf0QwlxD+HbjmR0pxnhM1DJruo23LtegFwRODDOHoaGSR/Gj7Ew +3fE1YRfrIDABSuw7k3h31NxYPydyS43FG2EfGMK5XP5w8n8+AOUtvo1YnXLCajmPSIJ PTLh9RU/JODa3idyW1umlE22o3QM9gfnDQ/UlLtsrDhIh+JtGG0xUNCm37xge7XIBlz8 TfiA== 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 j127si2250687wmg.16.2017.11.03.09.48.47; Fri, 03 Nov 2017 09:48:48 -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 5E3F3689E18; Fri, 3 Nov 2017 18:48:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0F1F689BF2 for ; Fri, 3 Nov 2017 18:48:28 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1eAf95-0006Ug-2J for ffmpeg-devel@ffmpeg.org; Fri, 03 Nov 2017 17:48:39 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id VUoV1w01x0S5wYM01UoWnu; Fri, 03 Nov 2017 17:48:31 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 3 Nov 2017 17:48:29 +0100 Message-Id: <20171103164829.6970-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.15.0 Subject: [FFmpeg-devel] [PATCH] avcodec/xan: Check for bitstream end in xan_huffman_decode() 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: 3707/clusterfuzz-testcase-6465922706440192 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/xan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 8b4ec82405..1ccf164847 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -131,7 +131,10 @@ static int xan_huffman_decode(uint8_t *dest, int dest_len, return ret; while (val != 0x16) { - unsigned idx = val - 0x17 + get_bits1(&gb) * byte; + unsigned idx; + if (get_bits_left(&gb) < 1) + return AVERROR_INVALIDDATA; + idx = val - 0x17 + get_bits1(&gb) * byte; if (idx >= 2 * byte) return AVERROR_INVALIDDATA; val = src[idx];