Commit e899cc8ab6 for ffmpeg
commit e899cc8ab64f173297d3c9350319f72f5b517e44
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sun Nov 22 17:42:07 2026 -0500
avformat/ogg/muxer: reject identification headers shorter than their layout
Xiph-laced extradata gives the size of the identification header, which
the splitter does not compare with the size the codec defines. The Theora
setup then reads its fields past the end of a shorter header.
The check applies the size each codec defines to Vorbis as well, whose
identification header is always 30 bytes long.
diff --git a/libavformat/ogg/muxer.c b/libavformat/ogg/muxer.c
index 69b9a679b9..73790d52a1 100644
--- a/libavformat/ogg/muxer.c
+++ b/libavformat/ogg/muxer.c
@@ -607,10 +607,12 @@ static int ogg_init(AVFormatContext *s)
const char *cstr = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
int header_type = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
int framing_bit = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
+ int first_header_size = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42;
if (avpriv_split_xiph_headers(st->codecpar->extradata, st->codecpar->extradata_size,
- st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
- (const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
+ first_header_size,
+ (const uint8_t**)oggstream->header, oggstream->header_len) < 0 ||
+ oggstream->header_len[0] < first_header_size) {
av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
oggstream->header[1] = NULL;
return AVERROR_INVALIDDATA;