From patchwork Wed Jan 11 23:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39979 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132458pzb; Wed, 11 Jan 2023 15:54:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1S391xee8vF7clTaR+rlZ8SV0fLR/yxe7IDoPd/X8OLkbAVtJS4FW56+ksXgPbDCgdkLL X-Received: by 2002:a17:907:3e26:b0:7ad:c8d7:4fd9 with SMTP id hp38-20020a1709073e2600b007adc8d74fd9mr83897413ejc.36.1673481287732; Wed, 11 Jan 2023 15:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481287; cv=none; d=google.com; s=arc-20160816; b=yh4eQa4WOlUS1xzVi421z3+Gck+puMOcR2/B93+DudE8138tjNPE3M2epHMuE+PLk2 vsrciDDx+pm/lxgsp8sfaFIjKCjKOM8J4Iks7SWV7yxvnEghlngx+hY5Px/ZCokumT9V iTTSUCnZ/No+LrJDK/+iednDC2JGMiXV9NnTfVEn/JdXpuaszbcKxDXRfQYKjFjHAGft hYeW5u5OLGdVUrcbJt7bTnWibwmuOqyE4rDNl0SNpoYSp13YG2TwFPAM2JQm6kfUxYFW eqmf1g2Qg3EOmYwIkbLkUeXSqwx8R/8bTJrKAf8iQyZ7cTL2Qmo8qC3Z+IfsRjBLNK3T YGlQ== 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; bh=vh5OtanMsey8HHO/sjX3Q4XCSOvnFI8sRSoKgkGHFY0=; b=NbopHGN0gyXRrVBuMTE1cVrdxJOh/ye/gAXxYCadYhwteyuSMYOiyGGHkjIx5fJOtD mcUEqQEngo7Tyjt0YJlNxPae6SCNUv3XUUmrA8LU45DVidEhILb9o5HuQW8+p3AtfP5Q CLSEoVowRGxIs/o88U6Jmb5yhsg4vD+jbUcfT1vTSm8A2OCU0jPi5zzd7Rm9WIhlndPj 1OYsIiPbtEzYeabsVVgQHAXCpFwPsTkyM68yzo3JaoldOD2BfVv/G5/mKaUl6LqhvTtA GLlzBlAo3AA06rwZ8EzrPg6OjXyaoWlHSZehHY367evFxxTpyiT4EPLmH3J75DBZpYKp gZsQ== 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 hw20-20020a170907a0d400b0084cbf5552b3si12350315ejc.970.2023.01.11.15.54.44; Wed, 11 Jan 2023 15:54:47 -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 CA31068BCFC; Thu, 12 Jan 2023 01:54:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D8E468A4CA for ; Thu, 12 Jan 2023 01:54:34 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 92FFF240004 for ; Wed, 11 Jan 2023 23:54:33 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:27 +0100 Message-Id: <20230111235432.2135-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/6] avcodec/eatgq: : Check index increments in tgq_decode_block() 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: rJTHlixEJjRC Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGQ_fuzzer-6743211456724992 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/eatgq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 89e9f20880..beb9f4d046 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -56,7 +56,7 @@ static av_cold int tgq_decode_init(AVCodecContext *avctx) return 0; } -static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb) +static int tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb) { const uint8_t *scantable = ff_zigzag_direct; int i, j, value; @@ -64,6 +64,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb for (i = 1; i < 64;) { switch (show_bits(gb, 3)) { case 4: + if (i >= 63) + return AVERROR_INVALIDDATA; block[scantable[i++]] = 0; case 0: block[scantable[i++]] = 0; @@ -73,6 +75,8 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb case 1: skip_bits(gb, 2); value = get_bits(gb, 6); + if (value > 64 - i) + return AVERROR_INVALIDDATA; for (j = 0; j < value; j++) block[scantable[i++]] = 0; break; @@ -100,6 +104,7 @@ static void tgq_decode_block(TgqContext *s, int16_t block[64], GetBitContext *gb } } block[0] += 128 << 4; + return 0; } static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)[64], AVFrame *frame, From patchwork Wed Jan 11 23:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39980 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132508pzb; Wed, 11 Jan 2023 15:54:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXtwsJYe2A/NWrv8m40T6Oj3vFsfU2q06Uf2R2IHJ4Y1DB4Aa5snB4IB0KCOVvKT+aSTQlLA X-Received: by 2002:a05:6402:1944:b0:45c:835c:1ecc with SMTP id f4-20020a056402194400b0045c835c1eccmr73402256edz.26.1673481295832; Wed, 11 Jan 2023 15:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481295; cv=none; d=google.com; s=arc-20160816; b=dVjw4ZtoyObYKYtfHMnqqUorwOyJo1nfwxIiBie52sPWcauDLGD19xa1qAbDtPF/hR jRezr3hwimstLIJfzqA4E7Y3BrX16K9dAl3/F+do8dN6qPHLvgHG1kudj2SHVc8rz5YY 9VTpQacuXK14JgTsXoOg14v7zUa5DevbwdvsbNyxzQ9aQZU0bwKOjpvdJByk4dd3f7/c uY8cKzhnYrYYdgAMM1uNzS9S1n6fMHMGXxJIpIxcmlbplbChyses+jp+7TOi9gjb5766 /f/mNxLVYKevt8wIxle9G3uyJySQmAO4lmifEgqG/1g8MF/Qm5ip+S9h3lIuHEMlr5t8 gAdw== 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=4Dnr4pvCKGdHaLzi7DHyY4FzYRg4yfnXEI8maPx7EAc=; b=BNfRgQSQabt5ftoq+xiL/Eyu1u6dJefI1W0mraWuFnTcDisKXMPSu4gMGakixDUNyR eZCUAcGYzhHNW9C0UtKenT2DRfA8svcJax6bsxa3VJEIKZEOG235zGC7tK9yxyRk2/HY pnJx6a8HFcl2ARtyQrUbKrLXr1yIw/VbzHP+xrO6KfAxCTNpGxi9xbuxaMNdqwaDhn06 jx61n+IabBOgFc41JNB14cKTM/hs1Fn9sP+ofxFolmYy+cy3bs6kOdC90F5cQ1ixJDWe gj4HjdOb/FnmyRqH2f8fys8g8eIcl0QuZhbPutyJHD0+Uu56gLh5RfJjjFAoeMk4JIXz y5tQ== 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 u9-20020aa7d889000000b004861295a0b7si14844145edq.332.2023.01.11.15.54.54; Wed, 11 Jan 2023 15:54:55 -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 15E8268BD60; Thu, 12 Jan 2023 01:54:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CD81168BD08 for ; Thu, 12 Jan 2023 01:54:35 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id A4418240004 for ; Wed, 11 Jan 2023 23:54:34 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:28 +0100 Message-Id: <20230111235432.2135-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> References: <20230111235432.2135-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/pngdec: Check deloco index more exactly 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: qF6rwNz4oqZA Fixes: out of array access: Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6716193709096960 Alternatively it should be possible to limit this to 3 plane RGB 8 /16bit to ensure the size is what it should be Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/pngdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index f1cad26c52..cb4162d2ab 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -322,7 +322,7 @@ void ff_png_filter_row(PNGDSPContext *dsp, uint8_t *dst, int filter_type, static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \ { \ int i; \ - for (i = 0; i < size; i += 3 + alpha) { \ + for (i = 0; i < size - 2; i += 3 + alpha) { \ int g = dst [i + 1]; \ dst[i + 0] += g; \ dst[i + 2] += g; \ From patchwork Wed Jan 11 23:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39981 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132540pzb; Wed, 11 Jan 2023 15:55:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXuDW1zqQUqwFXUEhgC2+lBTAAej7sL4r7AiS1t3yqdAR4LiY0Sz4D2c5wbjYz5H5U6rLmed X-Received: by 2002:a17:906:3b53:b0:863:3a9b:6a79 with SMTP id h19-20020a1709063b5300b008633a9b6a79mr1912603ejf.63.1673481302935; Wed, 11 Jan 2023 15:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481302; cv=none; d=google.com; s=arc-20160816; b=QBk11kIDKneb6Rjk9uxANx8wMEBj7tDubkMpsHIxPZbsifyjmv9Z9j+pGzr9dZdQQB obGDByxSbRnIGUk9h8u+WlywZ67/I20nMnDGQI5Qhk1kPY6bxPdtOcWCXyhAANBUV+wy P24RNbWnbYUrLt16+FmjyJJxYq/WVVlfgZKvodVcgQELZFIVshF0ScsX7M2aKoNLFHZe 89m9C23R/n5HJTsyzvppTPmru9Wysew5WW77ItBwpNn4V5cpaQ54/SChd/RF/Zx77k3Q xIFWBeRjk/FzvcqUH8QgzpSes899ieiiUlY1n6U8TNrIWC8F98/YR86uOQv6k0TagfTi 10iQ== 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=FYtyuQX3jK3/CrDIkvDftjPpLSGDDr2Bd8/C9Updu8A=; b=NTiY6wTCR6vLZRhFyTgRhdXUW0M9hms1VkYNB+D1dmSxOyPW4tdz8e7ZxLGBOf4Kbv 2jifPEgtqdDU0r/kc6G78yZnpbfkoSa9R2bhDpiQAkHQmp/qwD+S6aMDFJcKYc69wQMh Vruj2uQlLdiX10jnWe7kQ9vYtVix8S8Q3nO9tEN/3+A0J2Kkju7QIGJLXJEtB6Y6U7oM r63/mdjUy8qeKsOYb8JIy9ArYTHCubC1NTKeBEechSEP8tyjuWfWpSYEPogXy6M1xpNE /+oBtzqgA9qOZwHbG66ULVd4/UMPWLXOhPgh4GpUgtLmSUOlnz+/jiz2ysUsKREEZG8Y nfWg== 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 hq23-20020a1709073f1700b007c0f2133931si17124733ejc.520.2023.01.11.15.55.02; Wed, 11 Jan 2023 15:55:02 -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 1DDA568BD96; Thu, 12 Jan 2023 01:54:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2125768BD08 for ; Thu, 12 Jan 2023 01:54:36 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 723DF240002 for ; Wed, 11 Jan 2023 23:54:35 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:29 +0100 Message-Id: <20230111235432.2135-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> References: <20230111235432.2135-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/pngdec: dont skip/read chunk twice 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: ImjKiWHYXGkA Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PNG_fuzzer-6668158952144896.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/pngdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index cb4162d2ab..95bcfb514a 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1231,6 +1231,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s, } av_log(avctx, AV_LOG_ERROR, ", skipping\n"); bytestream2_skip(&s->gb, length + 8); /* tag */ + continue; } } tag = bytestream2_get_le32(&s->gb); From patchwork Wed Jan 11 23:54:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39982 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132603pzb; Wed, 11 Jan 2023 15:55:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXsyIlSkv7h4sne0jw6hcU8bGG02PWXOvPFHtNcON4DD8pwRTvHTJP/EMketMX+TK7K3lOAQ X-Received: by 2002:a17:907:8d16:b0:7c4:fa17:71fe with SMTP id tc22-20020a1709078d1600b007c4fa1771femr11671214ejc.45.1673481311663; Wed, 11 Jan 2023 15:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481311; cv=none; d=google.com; s=arc-20160816; b=iN/ds2Xn6x8tC7bHYCL4Mjtcjg8LTivR0qZTx9hfh1aw+dNjhyMjc1/15PEWXfFpsh ioHGhf9HzYLH9RKqZY9++yIDo30+TsWosOcY3JuoXyl3Lj3lJlpUe3FSwFuQCKVeq7ZN QZhsYBu2ZEARWeyAUnyOgA0MQSir8DtjsuNowl23txJqxvvr3j+pQE1opy97x3DRDlAy NFnzODyAYiGyF4492rPpHN+fgG+SrjzEWVyysOMKz2QfiY3n56cwn6P++E9yayUolvdQ ygNDoyG8Q56cee/z3cC8j3sXdPFhXBqdm6Co5fdoRjnxJQ7dU3pMRMg/QRHYTM4yucad NNUA== 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=hYXceapQ9goyBgSf2ExdLFcPf++XAUiXZ8zJ89qLS5M=; b=s9JPgJdFWMdia5jS9ihM6gYzZm6oNywB9htAzjGJ06SWT9nA41nhHmVURBPUAwL2D6 A+Qf+ndhJf5kiI/kdkxf7Ec0o1DqsBwkwvAUqyGKiuOZBKp9IV3ZFbs6UP5CUWMNECE1 w6XqrlDkVVOZmPcrLcBKkjcBheOWRGtu9Yk52tTc7yBwxFPwb1jU0b//K7aE2XmSJjsx XHozj0eW51znQG6ixxHZ2R6UVJ5FiOGXS9MeewNmvajZXh2NohPfRuIaKNS6xdzM8L0j pwdjx2Shn3nm2tMavLDooxc0/3WITUUoljmEXQ/cV/pO0r8qXh24CutnfTYzcLofQsfc BWWw== 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 xe9-20020a170907318900b007c12a22dc43si15013696ejb.662.2023.01.11.15.55.10; Wed, 11 Jan 2023 15:55:11 -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 481EB68BD9A; Thu, 12 Jan 2023 01:54:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29DC268BD39 for ; Thu, 12 Jan 2023 01:54:37 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 7535320005 for ; Wed, 11 Jan 2023 23:54:36 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:30 +0100 Message-Id: <20230111235432.2135-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> References: <20230111235432.2135-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/sgidec: do not forget the number of components in read_uncompressed_sgi() 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: WEdtc/WFrjS7 Fixes: out of array access Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6704753329700864 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6683986844057600 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGI_fuzzer-6697387691474944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/sgidec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index 6ff2ee97f6..92083f23de 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -159,7 +159,7 @@ static int read_uncompressed_sgi(uint8_t *const out[4], const ptrdiff_t stride[4 unsigned rowsize = width * bytes_per_channel; /* Test buffer size. */ - if (rowsize * (int64_t)height > bytestream2_get_bytes_left(g)) + if (rowsize * (int64_t)height * nb_components > bytestream2_get_bytes_left(g)) return AVERROR_INVALIDDATA; for (unsigned z = 0; z < nb_components; z++) { From patchwork Wed Jan 11 23:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39983 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132633pzb; Wed, 11 Jan 2023 15:55:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXtzYKGZNhT5b/UJeft7T1j28s8EuseYcXLb2oxZRsTgUXKgTg3O0UmE3gmJ0cZ6jxxDC662 X-Received: by 2002:aa7:d752:0:b0:499:bcfc:f47b with SMTP id a18-20020aa7d752000000b00499bcfcf47bmr9898548eds.16.1673481319242; Wed, 11 Jan 2023 15:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481319; cv=none; d=google.com; s=arc-20160816; b=GzQ6AbXrE2nCZfO/k7h4BFw4+1wZEJU/J9Z1IFXwN7zshzmhhzFxl8L5XaoheEFqjd DX44iSWlMKlH/Q3mgisek7J/EGTfN5fnEwBNWMj3WE6Ii2v4n1qOBYlAj5TT7W1UrwDY WFO4ipYyy4yPOulLwjhZ1UoWxc0+fS/KVwY8KHJ7fVRntlkgVdDj4q9afcCYfFOy5kny a3sjSoN+WXoiGTG95p7lArEZKEkmWwhdol4JxS3JezBlVdBB6dTwEQ+fW+cpjjY7IJOD b0QUL9FdOl7tErEFLvsBxKn06ZNlPZDor3DMiL6hRO8F0tA+VDuEwIyPl555kAa16Qwj LJBQ== 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=B4wigN/jJleh1nrLwEOzUZj0l8lZvRZwcRQPH29h/a0=; b=CdOHTv/32p0MtojeixfgT4sXMW4V3ssVYR25m5xmMKzdq2dAwmi4bP4moTJNOKLeAA 4BU0pJp+ue6Y7msqnak5ozh5gjlJb4aky99arXtuqcXz/fuaAW5pBBoLvHF0Pj82bAQ8 9rvW0NE8k1Uq4OSkD9BLw2XyNwwg8B11ukkE6SiT5bBWLcTkYtM57I06CGT/Fl32u4Jc Ooaq3vmcSxbyn2UL5l/rhCQGpu4ojroiNA/DumbISenIYqtU91bwqdlEZEIIRzGI+pKr rnE1s71zANs7chvSGr+FoXOnq4XXwU17Z0HTdRfYGrry8Xw3pQbD1dT3ExA3ULcQ93yp /1Vg== 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 d22-20020a056402401600b0048ef8cd7fe6si16481017eda.185.2023.01.11.15.55.18; Wed, 11 Jan 2023 15:55:19 -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 5501A68BCE4; Thu, 12 Jan 2023 01:54:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7B4368BCE4 for ; Thu, 12 Jan 2023 01:54:37 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 43442240007 for ; Wed, 11 Jan 2023 23:54:37 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:31 +0100 Message-Id: <20230111235432.2135-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> References: <20230111235432.2135-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things 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: IjTIAPFWsp+X Fixes: subtraction of unsigned offset from 0xf6602770 overflowed to 0xf6638c80 Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-495074400600064 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/videodsp_template.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/videodsp_template.c b/libavcodec/videodsp_template.c index 324d70f2cb..d653f4d524 100644 --- a/libavcodec/videodsp_template.c +++ b/libavcodec/videodsp_template.c @@ -64,7 +64,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, av_assert2(start_x < end_x && block_w); w = end_x - start_x; - src += start_y * src_linesize + start_x * sizeof(pixel); + src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel); buf += start_x * sizeof(pixel); // top @@ -87,7 +87,7 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, buf += buf_linesize; } - buf -= block_h * buf_linesize + start_x * sizeof(pixel); + buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel); while (block_h--) { pixel *bufp = (pixel *) buf; From patchwork Wed Jan 11 23:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39984 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp5132678pzb; Wed, 11 Jan 2023 15:55:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvakgJ1s1STY9eDl9uFIXy7xupbGwprfNb3lr1g1YIy5xjm22K8gRk99McpsBQXOZOhkvcO X-Received: by 2002:a17:906:b1c5:b0:84d:14c8:b669 with SMTP id bv5-20020a170906b1c500b0084d14c8b669mr18652146ejb.77.1673481326346; Wed, 11 Jan 2023 15:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673481326; cv=none; d=google.com; s=arc-20160816; b=q7bcfZEaCNep8D1reqXPXJKsRqwF7IK+3z6Iw2RF4/Yu0x38iRUjPTLOjNHKdETw5R 69f+/X3xYlzgtLx1gIxUIakm7bZXIOFoyJjINyEbnq30EE+0oSj7J87EMJ9vWcdX0FyQ hTf2nTNdS8HrvQMvWV4pRh/RMzb+B4wYykMB2FmbwXbkB6D75mG4rXFApI4aHQKu+FNB +K5IOf9lKdoFl0BMWs7YaDgPJf7jnoED+CRtk8Vkv0S7Q2wH7/gSKWkNP505BDl+ijiJ 7U902/93ZSotJiQbuNncCRloGbiiVvGWH0M0Jzz4RG/0CEZuj7gZoQl5T2jVt0KOxnTK Pbhw== 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=z3Gi/aSD0TXhcYaq+KjLBcwHEVqATNQruO5iM2Tcp7Y=; b=BCZBYn/P3GDS+9JjekmrQwHDd3V3Pqkg9pBIEnpYgbQo8FNmnXrXe3AUPK2B6CYz4U T/Cqo7kRgEPG/a7cc84G3r7V85EoGbuxnTldnQy8VC9BuNV7MNb8h8orM59Nw0EA7HKY OsnBcpvV+ViSHSoJOaf5THSl8fPa3j+EGdHeJh1DcCQGXM59EGPvihWbppT8nALFj31m 3h13T7KKfANKrdArkAQvhfyBjFn7r6CLkU64jJu/1sLDBRr2b4O26EaiVixyQ75qxKBI X6miSgpOPELTBJvcmxQsvYl0B4YZ+aS7/8D9rCuPekjaKXugS3SOdwaEshcKm89XRbjz 6wgg== 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 gn9-20020a1709070d0900b007aed5ffeffbsi19804039ejc.78.2023.01.11.15.55.26; Wed, 11 Jan 2023 15:55:26 -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 39F6D68BDA5; Thu, 12 Jan 2023 01:54:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0C56468BD94 for ; Thu, 12 Jan 2023 01:54:38 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 4E1C61BF203 for ; Wed, 11 Jan 2023 23:54:37 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 12 Jan 2023 00:54:32 +0100 Message-Id: <20230111235432.2135-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230111235432.2135-1-michael@niedermayer.cc> References: <20230111235432.2135-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 6/6] avcodec/tiff: do not try to read a value from a 0 value linearization table 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: 6j36ByhC8bib Fixes: index 4294967295 out of bounds for type 'uint16_t [65536]' Fixes: 48567/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-6666195176914944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/tiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 1a1879de89..c3f67860db 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -1451,7 +1451,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) break; case TIFF_GRAY_RESPONSE_CURVE: case DNG_LINEARIZATION_TABLE: - if (count > FF_ARRAY_ELEMS(s->dng_lut)) + if (count > FF_ARRAY_ELEMS(s->dng_lut) || count < 1) return AVERROR_INVALIDDATA; for (int i = 0; i < count; i++) s->dng_lut[i] = ff_tget(&s->gb, type, s->le);