From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 6A87A4BDC9 for ; Thu, 24 Jul 2025 16:40:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 77A7668C1AB; Thu, 24 Jul 2025 19:40:27 +0300 (EEST) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id C3B3D68D0AB for ; Thu, 24 Jul 2025 19:40:20 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0816C442A2 for ; Thu, 24 Jul 2025 16:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1753375220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MnJXDfG0uNYTKzsc6yDj1nehAoL9ZN0vHQUtiCkTabg=; b=MeGubkfzb3BBdBMWDsEPW99A0rdqOkdCEWGq1PB/QrVznEh4inaLZgWcBfw6aMCoc4SnFl PSEfmvmpPPP2/wSsPZHY88Bga8Pd8sdM0zQKqKetE63Yqvtvvd+TlQaRBC+ZhxKIBDMGiX 6KfBS1dIV4MjKmPXR2HqfJ9UBpATqXSZFRHezAYUj1n8z2cZORjrd3ZWnNUnW6bxpVaTBn Vsf0mG7g06z6njvkVgm02wSusSmMU5g7ijye+6wfp9d+/QDYEqQa8FcluRTpxTD5XAROhu ZNYOisnllql7m3kiIamvg5lTOomGo2mIaP9sgm4l4HvJujYQLxmbzkEMKgE+bQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 24 Jul 2025 18:40:17 +0200 Message-ID: <20250724164019.773541-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdekudduhecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepjeffueefffevvedthfeuvedtfeejteehieetffehteegvdduudevtdfffeejhfelnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepgedurdeiiedrieehrddujeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieehrddujeeipdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/shorten: Clear the additionally allocated space on realloc 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 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: use of uninitialized memory Fixes: 421954767/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-515682786246656 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/shorten.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index ad2e7588d69..bed92936801 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -584,7 +584,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (avpkt->size) { int max_framesize = s->blocksize * s->channels * 8; void *tmp_ptr; - + unsigned old_allocated_bitstream_size = s->allocated_bitstream_size; tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, max_framesize + AV_INPUT_BUFFER_PADDING_SIZE); if (!tmp_ptr) { @@ -592,9 +592,8 @@ static int shorten_decode_frame(AVCodecContext *avctx, AVFrame *frame, return AVERROR(ENOMEM); } s->bitstream = tmp_ptr; - if (max_framesize > s->max_framesize) - memset(s->bitstream + s->max_framesize, 0, (max_framesize - s->max_framesize) + - AV_INPUT_BUFFER_PADDING_SIZE); + if (s->allocated_bitstream_size > old_allocated_bitstream_size) + memset(s->bitstream + old_allocated_bitstream_size, 0, s->allocated_bitstream_size - old_allocated_bitstream_size); s->max_framesize = FFMAX(s->max_framesize, max_framesize); *got_frame_ptr = 0; goto finish_frame; -- 2.50.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".