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 A731641D2B for ; Thu, 22 Sep 2022 18:09:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 56D3368BA76; Thu, 22 Sep 2022 21:09:00 +0300 (EEST) Received: from vie01a-dmta-at03-3.mx.upcmail.net (vie01a-dmta-at03-3.mx.upcmail.net [62.179.121.153]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A995E68B745 for ; Thu, 22 Sep 2022 21:08:54 +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 1obQd3-004DLa-9I for ffmpeg-devel@ffmpeg.org; Thu, 22 Sep 2022 20:08:53 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id bQd2oTu7u8s8UbQd2oVNj7; Thu, 22 Sep 2022 20:08:53 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id bQd2oMsWAOG5ZbQd2oukzn; Thu, 22 Sep 2022 20:08:52 +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=KJo5sHJo c=1 sm=1 tr=0 ts=632ca4b4 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=0M_FlJwTtlK87it4aIcA:9 a=l4P9q1pZc1p6QgeJVkBh:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 22 Sep 2022 20:08:51 +0200 Message-Id: <20220922180852.20655-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfBCAGiwcYLelpk1yKpVKI3N3rqN96NxFL0bqa4OC9o8ywMs9agaWmu6X3dnPKL5jZm1gr8Yi9t29rpW/jV1Br1TYPulz37JZLxyeCDjxPa1G+ZfdqBQR UPiuj/VKWgj9R+oyIpw7AA/ZVkY9gB+jOB4zirT6p4EwwwVwuXl8LvdrfibX8Ib6azhYLeQwZ/098g== Subject: [FFmpeg-devel] [PATCH 1/2] avformat/vividas: Check 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: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/vividas.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavformat/vividas.c b/libavformat/vividas.c index e9954f73ed0..e8efe49a5c0 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -683,6 +683,7 @@ static int viv_read_packet(AVFormatContext *s, if (viv->sb_entries[viv->current_sb_entry].flag == 0) { uint64_t v_size = ffio_read_varlen(pb); + int last, last_start; if (!viv->num_audio) return AVERROR_INVALIDDATA; @@ -704,14 +705,22 @@ static int viv_read_packet(AVFormatContext *s, start = ffio_read_varlen(pb); pcm_bytes = ffio_read_varlen(pb); - if (i > 0 && start == 0) - break; + if (i > 0) { + if (start == 0) + break; + if (start < last || start - (unsigned)last > INT_MAX) + return AVERROR_INVALIDDATA; + } viv->n_audio_subpackets = i + 1; + last = viv->audio_subpackets[i].start = start; viv->audio_subpackets[i].pcm_bytes = pcm_bytes; } + last_start = viv->audio_subpackets[viv->n_audio_subpackets].start = (int)(off - avio_tell(pb)); + if (last_start < last || last_start - (unsigned)last > INT_MAX) + return AVERROR_INVALIDDATA; viv->current_audio_subpacket = 0; } else { -- 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".