Commit 32cc1cf4c1 for ffmpeg
commit 32cc1cf4c1573a99433182f47ba6839d0d9f06d4
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Nov 6 03:52:56 2026 +0100
avformat/nsvdec: fail on aux chunks larger than the video size
Fixes: N4g8ebEjqVoK
Fixes: swarm-Unsigned-vsize-underflow-in-NSV-aux-chunk-parsing-07da0a
Found-by: zhang xingxing <2388969553@qq.com>
Wrong error code Replicated through UnModified FFmpeg
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index b18fc46a4e..1ea5364f47 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -587,6 +587,8 @@ null_chunk_retry:
auxsize = avio_rl16(pb);
auxtag = avio_rl32(pb);
avio_skip(pb, auxsize);
+ if (vsize < auxsize + sizeof(uint16_t) + sizeof(uint32_t))
+ return AVERROR_INVALIDDATA;
vsize -= auxsize + sizeof(uint16_t) + sizeof(uint32_t); /* that's becoming brain-dead */
}