PR #23234 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23234
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23234.patch

The size field could be wrong while the actual payload is valid.


>From 938b1b2f43d85941c402f8f9cc68ae48a5d60ad0 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Mon, 25 May 2026 19:14:40 -0300
Subject: [PATCH] avformat/mov: allow outputting potentially truncated APV
 packets

The size field could be wrong while the actual payload is valid.

Signed-off-by: James Almer <[email protected]>
---
 libavformat/mov.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index d0d4910676..dcb7951d14 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -11618,12 +11618,15 @@ static int mov_read_packet(AVFormatContext *s, 
AVPacket *pkt)
         }
 #endif
         else if (st->codecpar->codec_id == AV_CODEC_ID_APV && sample->size > 
4) {
-            const uint32_t au_size = avio_rb32(sc->pb);
+            uint32_t au_size = avio_rb32(sc->pb);
+            int explode = !!(mov->fc->error_recognition & AV_EF_EXPLODE);
             if (au_size > sample->size - 4) {
-                av_log(s, AV_LOG_ERROR,
+                av_log(s, explode ? AV_LOG_ERROR : AV_LOG_WARNING,
                        "APV au_size %u exceeds sample body %d\n",
                        au_size, sample->size - 4);
-                return AVERROR_INVALIDDATA;
+                if (explode)
+                    return AVERROR_INVALIDDATA;
+                au_size = sample->size - 4;
             }
             ret = av_get_packet(sc->pb, pkt, au_size);
         } else
-- 
2.52.0

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

Reply via email to