GNOME Bugzilla – Bug 776345
gst-rtsp-server: segmentation fault when trying to get server port in TCP transport case
Last modified: 2017-01-10 10:42:01 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.
Are you planning to write a patch for this? Or do you have a testcase?
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.
I'm not sure, what is it actually used for in the TCP case?
I don't know, I would expect to get the sending TCP port in that case.
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).
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.
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.
Created attachment 343155 [details] [review] segfault in _get_server_port()
Please, have a look at my patch. Thanks in advance!
commit f47e6ab9f69ec1c77f8875ca41ee5ff268ab06ab Author: Patricia Muscalu <patricia@axis.com> 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. https://bugzilla.gnome.org/show_bug.cgi?id=776345
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;
Patricia, can you attach an additional patch for that with just the new change? Thanks :)
Created attachment 343214 [details] [review] incorrect if-statement in _get_server_port()
Fixed now. Sorry again!
Thanks! commit fb7833245de53bd6e409f5faf228be7899ce933f Author: Patricia Muscalu <patricia@axis.com> 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. https://bugzilla.gnome.org/show_bug.cgi?id=776345