From 3f24a38c8e264649a7bacd95ee4eee8c080a7d06 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Thu, 11 May 2023 15:28:35 +0200 Subject: [PATCH] sdpdemux: ensure that only one srcpad is created per stream If two senders use the same multicast IP and port then new_session_pad() may try to add a srcpad to the same stream twice. stream->srcpad is updated but gst_element_add_pad() fails the second time. As a result stream->srcpad points to a deleted object and access in gst_sdp_demux_stream_free() fails with a segfault. Just ignore the second pad. Nothing useful can be done with it anyway. Part-of: --- subprojects/gst-plugins-bad/gst/sdp/gstsdpdemux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst/sdp/gstsdpdemux.c b/subprojects/gst-plugins-bad/gst/sdp/gstsdpdemux.c index c2001b6154..22a2f75850 100644 --- a/subprojects/gst-plugins-bad/gst/sdp/gstsdpdemux.c +++ b/subprojects/gst-plugins-bad/gst/sdp/gstsdpdemux.c @@ -811,6 +811,9 @@ new_session_pad (GstElement * session, GstPad * pad, GstSDPDemux * demux) if (stream == NULL) goto unknown_stream; + if (stream->srcpad) + goto unexpected_pad; + stream->ssrc = ssrc; /* no need for a timeout anymore now */ @@ -851,6 +854,13 @@ new_session_pad (GstElement * session, GstPad * pad, GstSDPDemux * demux) return; /* ERRORS */ +unexpected_pad: + { + GST_DEBUG_OBJECT (demux, "ignoring unexpected session pad"); + GST_SDP_STREAM_UNLOCK (demux); + g_free (name); + return; + } unknown_stream: { GST_DEBUG_OBJECT (demux, "ignoring unknown stream");