PR #22576 opened by Scott Theisen (ulmus-scott)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22576
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22576.patch

ISO/IEC 13818-1:2021 specifies a valid range of [0x0010, 0x1FFE] in
§ 2.4.4.6 Semantic definition of fields in program association section
and Table 2-3 – PID table

ts->current_pid is always 0 since that is the PID for the PAT.

---

@cus
Since we don't verify that a program_number (sid in the code) occurs only once 
in a PAT, we may want to change the break statement to continue to ignore the 
invalid PID instead of not reading the rest of the PAT as an alternative to 
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21166 .

(We currently use the last entry for each program_number.)



From 71ed675b62de386afac9d521a454ac18eb74d269 Mon Sep 17 00:00:00 2001
From: Scott Theisen <[email protected]>
Date: Mon, 30 Jun 2025 00:21:45 -0400
Subject: [PATCH] libavformat/mpegts.c: pat_cb(): Ensure all PIDs are valid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

ISO/IEC 13818-1:2021 specifies a valid range of [0x0010, 0x1FFE] in
§ 2.4.4.6 Semantic definition of fields in program association section
and Table 2-3 – PID table

ts->current_pid is always 0 since that is the PID for the PAT.
---
 libavformat/mpegts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 4b326d309b..01b457589c 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2787,7 +2787,7 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
             break;
         pmt_pid &= 0x1fff;
 
-        if (pmt_pid == ts->current_pid)
+        if (pmt_pid <= 0x000F || pmt_pid == 0x1FFF)
             break;
 
         av_log(ts->stream, AV_LOG_TRACE, "sid=0x%x pid=0x%x\n", sid, pmt_pid);
-- 
2.52.0

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

Reply via email to