From 10680831353450834719002af12a68ea3d17002e Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 8 Sep 2020 10:48:56 +0200 Subject: [PATCH] mpegtsmux: Don't create streams with reserved PID There are quite a few reserved PID in the various MPEG-TS (and derivate) specifications which we should definitely not use. Those PID have a certain meaning and purpose. Furthermore, a lot of the code in the muxer implementation also makes assumption on the purpose of streams based on their PID. Therefore, when requesting a pad with a specific PID, make sure it is not a restricted PID. Part-of: --- gst/mpegtsmux/gstbasetsmux.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c index d2a73dd4f6..045c34ddb6 100644 --- a/gst/mpegtsmux/gstbasetsmux.c +++ b/gst/mpegtsmux/gstbasetsmux.c @@ -1268,6 +1268,10 @@ gst_base_ts_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, if (name != NULL && sscanf (name, "sink_%d", &pid) == 1) { if (tsmux_find_stream (mux->tsmux, pid)) goto stream_exists; + /* Make sure we don't use reserved PID. + * FIXME : This should be extended to other variants (ex: ATSC) reserved PID */ + if (pid < TSMUX_START_ES_PID) + goto invalid_stream_pid; } else { pid = tsmux_get_new_pid (mux->tsmux); } @@ -1288,6 +1292,13 @@ stream_exists: (NULL)); return NULL; } + +invalid_stream_pid: + { + GST_ELEMENT_ERROR (element, STREAM, MUX, + ("Invalid Elementary stream PID (< 0x40)"), (NULL)); + return NULL; + } } static void