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 2D20C4615E for ; Mon, 7 Aug 2023 00:50:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B8BE68C772; Mon, 7 Aug 2023 03:50:02 +0300 (EEST) 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 BEBF868C4FC for ; Mon, 7 Aug 2023 03:49:54 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3387A240003 for ; Mon, 7 Aug 2023 00:49:54 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 7 Aug 2023 02:49:49 +0200 Message-Id: <20230807004949.31634-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230807004949.31634-1-michael@niedermayer.cc> References: <20230807004949.31634-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/wavarc: Check that nb_samples is not negative 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: It is currently probably not possible for it to be negative as the needed 2Mb input buf size is not achievable. But it is more robust to check for it too. If it would become negative than code like s->samples[0][n] = s->samples[0][s->nb_samples + n]; would crash Signed-off-by: Michael Niedermayer --- libavcodec/wavarc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/wavarc.c b/libavcodec/wavarc.c index 0dc5849679..4bdd548d5f 100644 --- a/libavcodec/wavarc.c +++ b/libavcodec/wavarc.c @@ -311,7 +311,7 @@ static int decode_2slp(AVCodecContext *avctx, return AVERROR_EOF; case 8: s->nb_samples = get_urice(gb, 8); - if (s->nb_samples > 570) { + if (s->nb_samples > 570U) { s->nb_samples = 570; return AVERROR_INVALIDDATA; } @@ -587,7 +587,7 @@ static int decode_5elp(AVCodecContext *avctx, return AVERROR_EOF; case 11: s->nb_samples = get_urice(gb, 8); - if (s->nb_samples > 570) { + if (s->nb_samples > 570U) { s->nb_samples = 570; return AVERROR_INVALIDDATA; } -- 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".