This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit b5fc215e2d6567266f7f6c93bef6591972d8f8f6
Author:     Link Mauve <[email protected]>
AuthorDate: Mon May 4 17:25:58 2026 +0200
Commit:     Link Mauve <[email protected]>
CommitDate: Fri May 15 19:30:52 2026 +0000

    avformat/mods: Return EOF for packets starting at the index offset
    
    Assuming there is no padding between the last packet and the index, this
    prevents the index from being parsed as a normal packet, with non-
    sensical data.
---
 libavformat/mods.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavformat/mods.c b/libavformat/mods.c
index e18d89f220..7949bcd657 100644
--- a/libavformat/mods.c
+++ b/libavformat/mods.c
@@ -28,6 +28,10 @@
 #include "demux.h"
 #include "internal.h"
 
+typedef struct MODSDemuxContext {
+    uint32_t index_pos;
+} MODSDemuxContext;
+
 static int mods_probe(const AVProbeData *p)
 {
     if (memcmp(p->buf, "MODSN3\x0a\x00", 8))
@@ -44,6 +48,7 @@ static int mods_probe(const AVProbeData *p)
 static int mods_read_header(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
+    MODSDemuxContext *ctx = s->priv_data;
     AVRational fps;
     int64_t pos;
     int64_t timestamp;
@@ -72,6 +77,7 @@ static int mods_read_header(AVFormatContext *s)
     pos = avio_rl32(pb);
     num_keyframes = avio_rl32(pb);
     avio_seek(pb, pos, SEEK_SET);
+    ctx->index_pos = pos;
 
     for (int i = 0; i < num_keyframes; ++i) {
         timestamp = avio_rl32(pb);
@@ -94,6 +100,7 @@ static int mods_read_header(AVFormatContext *s)
 static int mods_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVIOContext *pb = s->pb;
+    MODSDemuxContext *ctx = s->priv_data;
     unsigned size;
     int64_t pos;
     int ret;
@@ -102,7 +109,11 @@ static int mods_read_packet(AVFormatContext *s, AVPacket 
*pkt)
     if (avio_feof(pb))
         return AVERROR_EOF;
 
+    /* This assumes the keyframes index directly follows the last packet. */
     pos = avio_tell(pb);
+    if (pos == ctx->index_pos)
+        return AVERROR_EOF;
+
     size = avio_rl32(pb) >> 14;
     ret = av_get_packet(pb, pkt, size);
     pkt->pos = pos;
@@ -120,6 +131,7 @@ const FFInputFormat ff_mods_demuxer = {
     .p.long_name    = NULL_IF_CONFIG_SMALL("MobiClip MODS"),
     .p.extensions   = "mods",
     .p.flags        = AVFMT_GENERIC_INDEX,
+    .priv_data_size = sizeof(MODSDemuxContext),
     .read_probe     = mods_probe,
     .read_header    = mods_read_header,
     .read_packet    = mods_read_packet,

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to