From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2A49C48260 for ; Fri, 15 Dec 2023 01:48:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B562E68D241; Fri, 15 Dec 2023 03:48:36 +0200 (EET) 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 B424C68D11B for ; Fri, 15 Dec 2023 03:48:30 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id 04BD81BF206 for ; Fri, 15 Dec 2023 01:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1702604910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:in-reply-to:in-reply-to:references:references; bh=mplAQEgUoDnHv2oobyTE8Z/VaVZKurEScLYMRvjzCDM=; b=GRpGfmWYHrOGnzoRuTwLISwg/A4CUHFxbE46fc1fhXS/DNZnwHOfAjLQp1N78qx/osOZG7 oT6zsMTTEHwd28HgC9qqD4ghpa3ObIxS5qQBoYydo6T7xAlpbBh7xvSWuI9kkvCxYAIUCp Hl6kiVhHy9Hz0vDj5ugJlUvI93/QaBPMKsmdOKzNXml8XQM1RqidAZ9zoiqBK/wYjQSLiM 4zRRNhpKQnQ+txwCEEaFvlb02QxRgAu1n2Ot6hlMahqy4syvckkA2h8/btA8Me1rP/v1T8 p4G/4URHkiqkVbsipKilj1zdg951TXcpZpAS9yEcS3qUsyNJRSfVUaXGvxfbNg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 15 Dec 2023 02:48:27 +0100 Message-Id: <20231215014828.8115-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231215014828.8115-1-michael@niedermayer.cc> References: <20231215014828.8115-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/jpegxl_parser: Add padding to cs_buffer 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes: out of array access Fixes: 64081/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6151006496620544 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpegxl_parser.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 006eb6b2954..a2f9a053018 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -162,7 +162,7 @@ typedef struct JXLParseContext { int skipped_icc; int next; - uint8_t cs_buffer[4096]; + uint8_t cs_buffer[4096 + AV_INPUT_BUFFER_PADDING_SIZE]; } JXLParseContext; /* used for reading brotli prefixes */ @@ -1391,7 +1391,7 @@ static int try_parse(AVCodecParserContext *s, AVCodecContext *avctx, JXLParseCon if (ctx->container || AV_RL64(buf) == FF_JPEGXL_CONTAINER_SIGNATURE_LE) { ctx->container = 1; ret = ff_jpegxl_collect_codestream_header(buf, buf_size, ctx->cs_buffer, - sizeof(ctx->cs_buffer), &ctx->copied); + sizeof(ctx->cs_buffer) - AV_INPUT_BUFFER_PADDING_SIZE, &ctx->copied); if (ret < 0) return ret; ctx->collected_size = ret; @@ -1400,7 +1400,7 @@ static int try_parse(AVCodecParserContext *s, AVCodecContext *avctx, JXLParseCon return AVERROR_BUFFER_TOO_SMALL; } cs_buffer = ctx->cs_buffer; - cs_buflen = FFMIN(sizeof(ctx->cs_buffer), ctx->copied); + cs_buflen = FFMIN(sizeof(ctx->cs_buffer) - AV_INPUT_BUFFER_PADDING_SIZE, ctx->copied); } else { cs_buffer = buf; cs_buflen = buf_size; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".