PR #24909 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24909
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24909.patch

avcodec/avcodec: document that a parser cannot be used after EOF 
Fixes: QjW951nk93s9
Found-by: Mike Murunov [genproof.com]


>From 4d8257d81c934a670a31a039b264e88e8062469f Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 6 Oct 2026 16:22:51 +0200
Subject: [PATCH 1/2] avcodec/avcodec: document that a parser cannot be used
 after EOF

Fixes: QjW951nk93s9
Found-by: Mike Murunov [genproof.com]
---
 libavcodec/avcodec.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index dcd19f8ff5..593ce08036 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2817,7 +2817,9 @@ AVCodecParserContext *av_parser_init(enum AVCodecID 
codec_id);
  * @param buf_size      buffer size in bytes without the padding. I.e. the 
full buffer
                         size is assumed to be buf_size + 
AV_INPUT_BUFFER_PADDING_SIZE.
                         To signal EOF, this should be 0 (so that the last frame
-                        can be output).
+                        can be output). After EOF has been signaled, only
+                        further calls with buf_size 0 are allowed; to parse
+                        new data, close the parser and allocate a new one.
  * @param pts           input presentation timestamp.
  * @param dts           input decoding timestamp.
  * @param pos           input byte position in stream.
-- 
2.52.0


>From 98f002a88918fecfc4a80d7f88a435c4dc0646e7 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Tue, 6 Oct 2026 16:22:51 +0200
Subject: [PATCH 2/2] avformat/flacdec: do not feed the parser after the EOF
 flush in flac_read_timestamp()

Once a read failed, only flush the parser until it returns no more data.

Found during triage of the security report QjW951nk93s9

Fixes: QjW951nk93s9
---
 libavformat/flacdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index e80b49307d..8d907bdc30 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -284,7 +284,7 @@ av_unused static int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
     AVPacket *const pkt = si->parse_pkt;
     AVStream *st = s->streams[stream_index];
     AVCodecParserContext *parser;
-    int ret;
+    int ret = 0;
     int64_t pts = AV_NOPTS_VALUE;
 
     if (avio_seek(s->pb, *ppos, SEEK_SET) < 0)
@@ -309,7 +309,8 @@ av_unused static int64_t 
flac_read_timestamp(AVFormatContext *s, int stream_inde
         uint8_t *data;
         int size;
 
-        ret = ff_raw_read_partial_packet(s, pkt);
+        if (ret >= 0 || ret == AVERROR(EAGAIN))
+            ret = ff_raw_read_partial_packet(s, pkt);
         if (ret < 0){
             if (ret == AVERROR(EAGAIN))
                 continue;
-- 
2.52.0

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

Reply via email to