From patchwork Sun Aug 5 20:29:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 9906 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp2540699jad; Sun, 5 Aug 2018 13:31:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf+oD1BWW2VZMVq0pWdPVxgVltuU+0D2VJIhV1Ebn6SVcwSpL4eJv5TSDVX6lmVD44aOO4z X-Received: by 2002:a1c:3743:: with SMTP id e64-v6mr9775308wma.63.1533501086241; Sun, 05 Aug 2018 13:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533501086; cv=none; d=google.com; s=arc-20160816; b=BaW3/jb1eFgWqQbJQzdd+ljG8ala3sHf+VRgob0FjK3bwYoPeV1pGEl90aDmh46TL7 LoF/sj92BSjyciu/P+PEDnBG8aHMdyaIbfAmPJ/YcAgGAdMWZ2kbKOBGSgI5H8UDLgA/ A/i+9pQjR2/FRYUWWTJlJo5nmmCOZsZIz262MBaFiHufB3/HhWkBV10VGkB3sj7pcnBT EBLWjV1rHunn+VOA3Rr8hz2JycwEHWmGR2mM9TlrVUkSJYX2wTLJqjhtd4FV8ZBYOkYm vjyq/Ufu7fBQYGQDtVynZHqEPJo/6DLm3Lz9B/ONGQs3eVmlbZ4XwBob+YQhwNFX5/8v lsWA== 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=uucAT+LYkbvhWxQsObq5+S72xi0MNlQInJTtjOXHqtw=; b=dwgYZmk1gH6hg6zVT5pbG32eqhpKsLiN2fnYjU6DLLZIoYGbBIPw0dmxSxMFYh7coz L7tsWl2J6zjIn4aBrC9hmjazc+TErX7I571B6/scL1lNsJO5313krzEvkx2+L/hciBoI LZIZJzSmwcVr/hK/ILd1y4mprnnySd8bO71oLfyKA5SnHvm5/hLGFHTLcYGeCrRKg8Qr uVZAOzsR6wwtGHb3CvfGsdqqMVTE9ZCyKMdgJVlSxG+nWKAwvOLrxckXgIJXRmFX/S4G 7W4WrMMGEvfcC6Jkpu+dlG51gBnOcTWcVodSib4NlpfAekwKxjuYO6lB0A8WPZcdZe0S 2ZCg== 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 h125-v6si4022028wmf.145.2018.08.05.13.31.25; Sun, 05 Aug 2018 13:31:26 -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 0C47668A4BE; Sun, 5 Aug 2018 23:30:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-1.mx.upcmail.net (vie01a-dmta-pe07-1.mx.upcmail.net [84.116.36.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19BFA68A4B7 for ; Sun, 5 Aug 2018 23:30:12 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1fmPfc-0005do-Hb for ffmpeg-devel@ffmpeg.org; Sun, 05 Aug 2018 22:30:32 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id KYWN1y00b0S5wYM01YWPWX; Sun, 05 Aug 2018 22:30:23 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 5 Aug 2018 22:29:37 +0200 Message-Id: <20180805202937.7563-9-michael@niedermayer.cc> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180805202937.7563-1-michael@niedermayer.cc> References: <20180805202937.7563-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 9/9] avcodec/gdv: Error out if we had insufficent input for the output frame in decompress_2() 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 (with the previous commits to gdv.c) Fixes: 9422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5143490001371136 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/gdv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c index d497f76157..b54f7373d1 100644 --- a/libavcodec/gdv.c +++ b/libavcodec/gdv.c @@ -230,6 +230,10 @@ static int decompress_2(AVCodecContext *avctx) break; } } + + if (bytestream2_get_bytes_left_p(pb) > 0) + return AVERROR_INVALIDDATA; + return 0; } @@ -458,6 +462,8 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data, default: av_assert0(0); } + if (ret < 0) + return ret; memcpy(frame->data[1], gdv->pal, AVPALETTE_SIZE); dst = frame->data[0];