[FFmpeg-devel] [PATCH 10/13] avformat/vividas: Check packet size

Michael Niedermayer michael at niedermayer.cc
Sun Sep 18 20:14:07 EEST 2022


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 <michael at niedermayer.cc>
---
 libavformat/vividas.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index e9954f73ed0..22f61db7576 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -643,7 +643,9 @@ static int viv_read_packet(AVFormatContext *s,
 
     if (viv->current_audio_subpacket < viv->n_audio_subpackets) {
         AVStream *astream;
-        int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start;
+        int64_t size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - (int64_t)viv->audio_subpackets[viv->current_audio_subpacket].start;
+        if (size < 0 || size != (int)size)
+            return AVERROR_INVALIDDATA;
 
         pb = viv->sb_pb;
         ret = av_get_packet(pb, pkt, size);
-- 
2.17.1



More information about the ffmpeg-devel mailing list