From patchwork Wed Jan 31 18:20:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7459 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp2047417jak; Wed, 31 Jan 2018 10:20:48 -0800 (PST) X-Google-Smtp-Source: AH8x226zE6c/iKWP0qNQqcoIcYCQxSUE1IWM+QnytkHxTnW7MrEvsbyCMicoMOJvWi1HeZ5iambh X-Received: by 10.223.190.143 with SMTP id i15mr10910838wrh.145.1517422848913; Wed, 31 Jan 2018 10:20:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517422848; cv=none; d=google.com; s=arc-20160816; b=D1Gh4TkE5t95nNT0sw1UvZiw7xd1+eUVUtV04ocKf91KfLU4IjUCxVmh7FTMcjJBPx NY7BQXQOixSntcGrSJKUyrFquOgTwlnaA1Pdpd9K+xRXLkQOsOxdV06I0ZUsZD4Kd8Uc 6j+wVx53phetrfd/7TwLwMB14CQ53IlHqah+ITwHAp9yqslEitYnVdWVXQgFLAILBwOy 6VkS8/FXyX+gzJyecFXwNGN4xVx11/bVh/UsD/+WRf/nnYsmZBOTuIM4n3CF+jyZLHzl R1/ien+G6C1qYiM8v99Pd1oJFDJyqxIwQNVHAHVGSi3/BUD62zLorVWpYT8p4n7kQC08 iEeQ== 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=EIO95X+CF09NzeP/w3Up601pfKj7yJKZ/7PE4TDXb9A=; b=KImA/O87Vl3jcGgpnvLYm2mmVxj0+y0Q+jFRck6plVM5rUwJyu8osuBrD5hT8XlKlZ EOLCT2exEC8ZFt8rIfgRbvzUsif5/ZsDTK3wEbSq3pvNmr8xX+EHb2GslDUXc/d18R3X Skm6Brs4Pn4is+hKLfYQAS+IA/gkZcWHpCIRJn3Q7LiSlbSAwEZdkCgqKgLJDsG/zmv9 8A72q+M3/0+IFffYDEXHP1VftQrZDEFp0RMCru5NEvQzjHoAlEVly/Bw/9hQ7VasQP71 K7fzZJaa4DGHZTWVCQyL/CEqCMD1POPbYOuRxWHCzonnQ/fi6QlzLPtemSHmEroIEXLa fEpw== 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 a25si14975824wrd.323.2018.01.31.10.20.48; Wed, 31 Jan 2018 10:20:48 -0800 (PST) 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 881E4689950; Wed, 31 Jan 2018 20:20:28 +0200 (EET) 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 8550068988E for ; Wed, 31 Jan 2018 20:20:21 +0200 (EET) Received: from [172.31.218.40] (helo=vie01a-dmta-pe04-1.mx.upcmail.net) by vie01a-pqmta-pe01.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1egwzi-0005Li-Rb for ffmpeg-devel@ffmpeg.org; Wed, 31 Jan 2018 19:20:26 +0100 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe04.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1egwzd-0002Y4-IQ for ffmpeg-devel@ffmpeg.org; Wed, 31 Jan 2018 19:20:21 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 56LD1x0170S5wYM016LEdt; Wed, 31 Jan 2018 19:20:14 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 31 Jan 2018 19:20:10 +0100 Message-Id: <20180131182010.8745-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180131182010.8745-1-michael@niedermayer.cc> References: <20180131182010.8745-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/huffyuvdec: Check input buffer size 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: 5487/clusterfuzz-testcase-4696837035393024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 979c4b9d5c..66357bfb40 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -919,6 +919,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVFrame *const p = data; int table_size = 0, ret; + if (buf_size < (width * height + 7)/8) + return AVERROR_INVALIDDATA; + av_fast_padded_malloc(&s->bitstream_buffer, &s->bitstream_buffer_size, buf_size);