Commit 94505b6444 for ffmpeg
commit 94505b6444bd321a656e820cd7556ce95e9056de
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 04:03:02 2026 +0200
avformat/idroqdec: compute the codebook and VQ packet size in 64bit
Fixes: yyLBi9GsHV9w
Packet size wraparound Replicated through UnModified FFmpeg
Found-by: zhang xingxing <2388969553@qq.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libavformat/idroqdec.c b/libavformat/idroqdec.c
index 76d96196ba..ad904b42b4 100644
--- a/libavformat/idroqdec.c
+++ b/libavformat/idroqdec.c
@@ -99,7 +99,7 @@ static int roq_read_packet(AVFormatContext *s,
RoqDemuxContext *roq = s->priv_data;
AVIOContext *pb = s->pb;
int ret = 0;
- unsigned int chunk_size;
+ int64_t chunk_size;
unsigned int chunk_type;
unsigned int codebook_size;
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
@@ -154,7 +154,7 @@ static int roq_read_packet(AVFormatContext *s,
avio_skip(pb, codebook_size);
if ((ret = ffio_read_size(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) < 0)
return ret;
- chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
+ chunk_size = (int64_t)AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
codebook_size;
if (chunk_size > INT_MAX)