From patchwork Thu Nov 2 23:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44485 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:181:818d:5e7f with SMTP id q28csp218890pzh; Thu, 2 Nov 2023 16:50:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsE7ilRdObEBjdT1lU1OixocYBEH51Jr3m7Glnx02ITJB3sdpGXlasBeFYY1G2WEF72ZFM X-Received: by 2002:a17:906:c02:b0:9c5:7f5d:42dc with SMTP id s2-20020a1709060c0200b009c57f5d42dcmr829721ejf.33.1698969046696; Thu, 02 Nov 2023 16:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698969046; cv=none; d=google.com; s=arc-20160816; b=RKKz89ZPMR1ncE3h8aUjpY8mKwtV5czvO01lyxmYlpYanhhGTS4eaUq09NlM/NKUgD g4uq+HIDIU4NOoyqppHHWyS26nncuELxPNCA+L2cuAskeQ4zkL8fpO2+Xr+LXm25ej0C veoeIMPXszNZAK410G4Te5K8glwigiHj+zM0RXA5FziQnyoWEP4hR0PzXabttevdSNXF nCbU8Kd7dhYgTkK6C6UEhis5hK4gHVImuvPz/dNYzyMZQd3znny8Q7oJEEpSpiHwj2vg Jv3tCXfac7LBfsrCC8qqhrixMJlPj4z/hZyDjHGl5jXYA7K0itc/CP8bhZ756mEQWITg z5Lw== 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=7A9myof2AKltED1PPKicbGwNsUehimIkA+TpT5h+akk=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=vkA2ZuC4oIXBVY3uhl5o1gvRJMuS48cAJanlSfi18JeA/XoD4OZqja4DmQikGTJmph rqPcMHG2JhdaNpfO7It1rb/WQCmSG1io0sO2ZVZqbhP2iqVvEd2jjk+XafOGeFl0Hyvi xg+Hh+jxd7KlilF2bFjTGv7hi1JWEyXixw783/tuu/y5Pr5UI7ZYXD9lVtxCNTf8WLfk 6qRooe6c+xpr85iDK7tw8fINyCuf3Uccm+BTzvParwnL7KjNMWLH6Pmfath7FoPuLsXo TjDgRA21HE630KeO3EAcbV24umNGV+HFkITN2XLz+BXMbvIrZskdCVhr1LEUraIkKyv3 L7BQ== 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 j14-20020a170906104e00b009d37ae5b894si301912ejj.643.2023.11.02.16.50.46; Thu, 02 Nov 2023 16:50:46 -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 8FD9D68CCED; Fri, 3 Nov 2023 01:50:26 +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 74C1068C1E2 for ; Fri, 3 Nov 2023 01:50:19 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id D1E69240005 for ; Thu, 2 Nov 2023 23:50:18 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 3 Nov 2023 00:50:15 +0100 Message-Id: <20231102235016.3935-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231102235016.3935-1-michael@niedermayer.cc> References: <20231102235016.3935-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/flicvideo: consider width in copy loops 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: invGc5wh5c9w Fixes: out of array write Fixes: 63520/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLIC_fuzzer-4876198087622656 Regression since: c7f8d42c12582b0626ea38117df6c9aea9fcf5b1 (was not posted to ffmpeg-devel) Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/flicvideo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c index 6ce033ba409..43f3f83bf65 100644 --- a/libavcodec/flicvideo.c +++ b/libavcodec/flicvideo.c @@ -642,7 +642,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx, "has incorrect size, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { - for (y_ptr = 0; check_pixel_ptr(y_ptr, 0, pixel_limit, direction) == 0; + for (y_ptr = 0; check_pixel_ptr(y_ptr, s->avctx->width, pixel_limit, direction) == 0; y_ptr += s->frame->linesize[0]) { bytestream2_get_buffer(&g2, &pixels[y_ptr], s->avctx->width); @@ -949,7 +949,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, if (bytestream2_get_bytes_left(&g2) < 2 * s->avctx->width * s->avctx->height ) return AVERROR_INVALIDDATA; - for (y_ptr = 0; check_pixel_ptr(y_ptr, 0, pixel_limit, direction) == 0; + for (y_ptr = 0; check_pixel_ptr(y_ptr, 2*s->avctx->width, pixel_limit, direction) == 0; y_ptr += s->frame->linesize[0]) { pixel_countdown = s->avctx->width; @@ -1235,7 +1235,7 @@ static int flic_decode_frame_24BPP(AVCodecContext *avctx, "bigger than image, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { - for (y_ptr = 0; check_pixel_ptr(y_ptr, 0, pixel_limit, direction) == 0; + for (y_ptr = 0; check_pixel_ptr(y_ptr, 3*s->avctx->width, pixel_limit, direction) == 0; y_ptr += s->frame->linesize[0]) { bytestream2_get_buffer(&g2, pixels + y_ptr, 3*s->avctx->width);