From patchwork Mon Jun 21 21:25:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 28592 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2042:0:0:0:0 with SMTP id z2csp2343871iod; Mon, 21 Jun 2021 14:26:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfSc7j0NV87Wg/vIJBUpxKTmxk4AGZtefqkaDs4SLIVAfoo905f/JB2poXvy247xT1q9Vo X-Received: by 2002:a17:906:4882:: with SMTP id v2mr203010ejq.134.1624310818979; Mon, 21 Jun 2021 14:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624310818; cv=none; d=google.com; s=arc-20160816; b=hWzt4mAj3+OzqKtYG/IVcLYasnlaosgUChtgdLAM9OZ9jCgdBxGhOsvgkwzU7XoPzM uAWTxqnOI3tdhSeEy7ycPLVa5296bCUZzRNl7PMM2vGq5xYrCG/0CRc+MB7kelokGfAk yGmh40YaO/Lrks96njmS0n5MT/y1Dt1dPc+XgArFHkPTdIhyz0dKaOulbZkloZfGPjSd dHDlm4qwOgY9S1TewNJFKfJzWBP4r9nckE8pfdrT3NSLnZOOduLvf+aJLY5vCaHc3JhU 3CULxCia8w/fsWE8iZaIdQvcYq9gOjlGvV3MoVQZB0SP4jfJJpbw+xKjJFae455UIgH2 3NKw== 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; bh=NXrRo/aB6s2S017cDwMbFNsOMYCWhN7w3ECdaTOP7mc=; b=ddsdjJlu4JFmObx7WfYB861qN9VF6qkn5oa2xf6hjqgwY4/mcJueCcDstcsc8TYNx/ wfiOaDWlSPqGh01X7KOAceCjWdLi7g+4Cn/KwnniFyB6zpOG+wB3DkfH7n9qsJQBKhfW CNsCRv2ZvxONRRAzmF78DlEemYDkc6UaJmBA8oy3m3fd6Zk4Hhvl3zGUDNV4CYBBH1CT Rt/atqPPN5MfD53K9gwyVrnY3FDLdv+b0yezGWZ1UwMeXuQ+anC1aGG8O4c3jMBlNwAe kxRhhaqPa06I/2HAErKb8VVBJhz5j6gnCTmAMerZsj1AWfKaGOdFawnOZh8cS5RHMsJn l8FA== 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 s13si15044025edy.85.2021.06.21.14.26.58; Mon, 21 Jun 2021 14:26:58 -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 F02DD689F00; Tue, 22 Jun 2021 00:26:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC4F568052B for ; Tue, 22 Jun 2021 00:26:46 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lvRRN-004Fiu-0E for ffmpeg-devel@ffmpeg.org; Mon, 21 Jun 2021 23:26:45 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id vRQPl0M4pljeHvRQPlc6Qu; Mon, 21 Jun 2021 23:25:45 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=OI1zSjG8bbiHpuWw3DcA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 21 Jun 2021 23:25:43 +0200 Message-Id: <20210621212544.15449-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210621212544.15449-1-michael@niedermayer.cc> References: <20210621212544.15449-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfPB7h9lGiyBCJka6qvSxX4Q4CEQw9jhheVzjosW0H0CvNaPBL8Gbu9HhVlRW+gx31IJvGa228r/d0bfGN/DYhsQC/F4T8L+UmlCblJJE0c0nKpp1A3C0 29wOyCEx7i1XfpAsCWeKaVP9SnC8ZjrE2CyuY+xhUFy1yrPa1KkO4wtp Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/exr: Better size checks X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 2PZz6eAWzy3h Fixes: signed integer overflow: 3530839700044513368 + 8386093932303352321 cannot be represented in type 'long long' Fixes: 35182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-5398383270428672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/exr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 4648ed7d62..e7387ffd66 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1014,7 +1014,7 @@ static int dwa_uncompress(EXRContext *s, const uint8_t *src, int compressed_size dc_count = AV_RL64(src + 72); ac_compression = AV_RL64(src + 80); - if (compressed_size < 88LL + lo_size + ac_size + dc_size + rle_csize) + if (compressed_size < (uint64_t)(lo_size | ac_size | dc_size | rle_csize) || compressed_size < 88LL + lo_size + ac_size + dc_size + rle_csize) return AVERROR_INVALIDDATA; bytestream2_init(&gb, src + 88, compressed_size - 88);