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 66AC640708 for ; Fri, 29 Apr 2022 18:24:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 04CF968B29B; Fri, 29 Apr 2022 21:24:39 +0300 (EEST) Received: from vie01a-dmta-at03-2.mx.upcmail.net (vie01a-dmta-at03-2.mx.upcmail.net [62.179.121.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 59EBC68B23D for ; Fri, 29 Apr 2022 21:24:32 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1nkVI1-00063r-BT for ffmpeg-devel@ffmpeg.org; Fri, 29 Apr 2022 20:24:25 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id kVI1nkvhKSgGFkVI1n4biP; Fri, 29 Apr 2022 20:24:25 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id kVHmnZB3FOPqFkVHmnxpBx; Fri, 29 Apr 2022 20:24:10 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=OcX7sjfY c=1 sm=1 tr=0 ts=626c2d59 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=NEAV23lmAAAA:8 a=VoiLvOrikwrOPNCf7twA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 29 Apr 2022 20:24:10 +0200 Message-Id: <20220429182410.5044-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220429182410.5044-1-michael@niedermayer.cc> References: <20220429182410.5044-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfDryi7iM/cJGcsXDgydMQQLHvbgHv9SHA7D8nTeHYSkYY8ncwdXemDaCJYXeucOKKHKBW79u1ZNKefuDt4vBss9y3Fj6vOyrueWy3Vd88nn7GrmM/qor NetwtvwoCcRcHns/ChsE1X6b74ixkBR4BB+T/wAzmx9M7FsE64RS3EEC6LH5+DhScUpzx+1A1/XGEg== Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/mpeg4videodec: Check pixel size against packet size 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: Timeout Fixes: 46866/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5114397204283392 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4videodec.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index e2bde73639..267a79a62f 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -2337,8 +2337,14 @@ static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) /* Do the same check as non-studio profile */ if (width && height) { if (s->width && s->height && - (s->width != width || s->height != height)) + (s->width != width || s->height != height)) { + if (width*height / 256 > get_bits_left(gb)) { + av_log(s->avctx, AV_LOG_ERROR, "Impossible size for this frame\n"); + return AVERROR_INVALIDDATA; + } + s->context_reinit = 1; + } s->width = width; s->height = height; } @@ -2485,8 +2491,13 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) if (width && height && /* they should be non zero but who knows */ !(s->width && s->codec_tag == AV_RL32("MP4S"))) { if (s->width && s->height && - (s->width != width || s->height != height)) + (s->width != width || s->height != height)) { + if (width*height/256 > get_bits_left(gb)) { + av_log(s->avctx, AV_LOG_ERROR, "Impossible size for this frame\n"); + return AVERROR_INVALIDDATA; + } s->context_reinit = 1; + } s->width = width; s->height = height; } -- 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".