After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776345 - gst-rtsp-server: segmentation fault when trying to get server port in TCP transport case
gst-rtsp-server: segmentation fault when trying to get server port in TCP tra...
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
git master
Other Linux
: Normal normal
: 1.10.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Reported: 2016-12-21 13:07 UTC by Patricia Muscalu
Modified: 2017-01-10 10:42 UTC
See Also:
GNOME target: ---
GNOME version: ---

segfault in _get_server_port() (3.56 KB, patch)
2017-01-09 13:25 UTC, Patricia Muscalu
committed Details | Review
incorrect if-statement in _get_server_port() (1.03 KB, patch)
2017-01-10 07:39 UTC, Patricia Muscalu
committed Details | Review

Description Patricia Muscalu 2016-12-21 13:07:22 UTC
Calling function gst_rtsp_stream_get_server_port() cases segmenation fault in
the RTP/RTSP/TCP case. The reason of this problem is that priv->server_addr_v4/ priv->server_addr_v6 are actually only initialized in UDP and MCAST cases.
The code does not handle the TCP port case.
Comment 1 Sebastian Dröge (slomo) 2016-12-22 11:50:06 UTC
Are you planning to write a patch for this? Or do you have a testcase?
Comment 2 Patricia Muscalu 2017-01-09 08:01:00 UTC
I can prepare a patch. I wonder if this function is only supposed to return the sending UDP port? If so, the fix is pretty simple.
Comment 3 Sebastian Dröge (slomo) 2017-01-09 11:05:28 UTC
I'm not sure, what is it actually used for in the TCP case?
Comment 4 Patricia Muscalu 2017-01-09 11:25:13 UTC
I don't know, I would expect to get the sending TCP port in that case.
Comment 5 Sebastian Dröge (slomo) 2017-01-09 11:27:07 UTC
I wouldn't know where it would be used in the context of TCP, can you trace where it ends up? My guess is that it's just completely unused, so you could as well return -1 there in this case (but that it's called at all seems problematic).
Comment 6 Patricia Muscalu 2017-01-09 11:37:08 UTC
It's called from our application (gathering some streaming statistics).
In the previous versions of gst-rtsp-server calling _get_port() didn't end up in segemenation fault.
Comment 7 Sebastian Dröge (slomo) 2017-01-09 11:44:52 UTC
Ah. So what is your application doing with it then? :)

It of course should not segfault, but it seems to me like returning 0 or -1 here in the TCP-only case seems to make most sense. The port does not really matter then, it only has a meaning in the UDP cases.
Comment 8 Patricia Muscalu 2017-01-09 13:25:10 UTC
Created attachment 343155 [details] [review]
segfault in _get_server_port()
Comment 9 Patricia Muscalu 2017-01-09 13:27:15 UTC
Please, have a look at my patch. Thanks in advance!
Comment 10 Sebastian Dröge (slomo) 2017-01-09 13:28:53 UTC
commit f47e6ab9f69ec1c77f8875ca41ee5ff268ab06ab
Author: Patricia Muscalu <>
Date:   Mon Jan 9 14:12:05 2017 +0100

    rtsp-stream: fixed segmenation fault in _get_server_port()
    Calling function gst_rtsp_stream_get_server_port() results in
    segmenation fault in the RTP/RTSP/TCP case.
    Port that the server will use to receive RTCP makes only
    sense in the UDP case, however the function should handle
    the TCP case in a nicer way.
Comment 11 Patricia Muscalu 2017-01-09 13:54:21 UTC
Sorry, but there is actually a "little" mistake in my patch:

diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c
index 6af69b4..445b924 100644
--- a/gst/rtsp-server/rtsp-stream.c
+++ b/gst/rtsp-server/rtsp-stream.c
@@ -1531,8 +1531,8 @@ gst_rtsp_stream_get_server_port (GstRTSPStream * stream,
   g_mutex_lock (&priv->lock);
-  if (family == G_SOCKET_FAMILY_IPV4 && priv->server_addr_v4) {
-    if (server_port) {
+  if (family == G_SOCKET_FAMILY_IPV4) {
+    if (server_port && priv->server_addr_v4) {
       server_port->min = priv->server_addr_v4->port;
       server_port->max =
           priv->server_addr_v4->port + priv->server_addr_v4->n_ports - 1;
Comment 12 Sebastian Dröge (slomo) 2017-01-09 16:09:16 UTC
Patricia, can you attach an additional patch for that with just the new change? Thanks :)
Comment 13 Patricia Muscalu 2017-01-10 07:39:56 UTC
Created attachment 343214 [details] [review]
incorrect if-statement in _get_server_port()
Comment 14 Patricia Muscalu 2017-01-10 07:42:09 UTC
Fixed now. Sorry again!
Comment 15 Tim-Philipp Müller 2017-01-10 10:41:48 UTC

commit fb7833245de53bd6e409f5faf228be7899ce933f
Author: Patricia Muscalu <>
Date:   Tue Jan 10 08:34:50 2017 +0100

    rtsp-stream: corrected if-statement in _get_server_port()
    This bug was accidentally introduced while fixing a segfault
    in _get_server_port() function.