mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst/rtsp/rtspconnection.c: Use threadsafe inet_ntop to convert an ip number to a string.
Original commit message from CVS: * gst/rtsp/rtspconnection.c: (rtsp_connection_connect), (rtsp_connection_close), (rtsp_connection_free): Use threadsafe inet_ntop to convert an ip number to a string. Fixes #447961. Don't leak fd (and ip) when freeing a connection without first closing it.
This commit is contained in:
parent
6fb347e76f
commit
ebce97adf5
2 changed files with 21 additions and 6 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-06-19 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/rtsp/rtspconnection.c: (rtsp_connection_connect),
|
||||||
|
(rtsp_connection_close), (rtsp_connection_free):
|
||||||
|
Use threadsafe inet_ntop to convert an ip number to a string.
|
||||||
|
Fixes #447961.
|
||||||
|
Don't leak fd (and ip) when freeing a connection without first closing
|
||||||
|
it.
|
||||||
|
|
||||||
2007-06-19 Jan Schmidt <thaytan@mad.scientist.com>
|
2007-06-19 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
|
@ -175,7 +175,8 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
|
||||||
struct sockaddr_in sa_in;
|
struct sockaddr_in sa_in;
|
||||||
struct hostent *hostinfo;
|
struct hostent *hostinfo;
|
||||||
char **addrs;
|
char **addrs;
|
||||||
gchar *ip;
|
const gchar *ip;
|
||||||
|
gchar ipbuf[INET_ADDRSTRLEN];
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
gint ret;
|
gint ret;
|
||||||
guint16 port;
|
guint16 port;
|
||||||
|
@ -207,7 +208,8 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
|
||||||
goto not_ip; /* host not an IP host */
|
goto not_ip; /* host not an IP host */
|
||||||
|
|
||||||
addrs = hostinfo->h_addr_list;
|
addrs = hostinfo->h_addr_list;
|
||||||
ip = inet_ntoa (*(struct in_addr *) *addrs);
|
ip = inet_ntop (AF_INET, (struct in_addr *) addrs[0], ipbuf,
|
||||||
|
sizeof (ipbuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the port from the url */
|
/* get the port from the url */
|
||||||
|
@ -264,7 +266,7 @@ rtsp_connection_connect (RTSPConnection * conn, GTimeVal * timeout)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
conn->fd = fd;
|
conn->fd = fd;
|
||||||
conn->ip = ip;
|
conn->ip = g_strdup (ip);
|
||||||
|
|
||||||
return RTSP_OK;
|
return RTSP_OK;
|
||||||
|
|
||||||
|
@ -1000,6 +1002,9 @@ rtsp_connection_close (RTSPConnection * conn)
|
||||||
|
|
||||||
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
|
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
|
||||||
|
|
||||||
|
g_free (conn->ip);
|
||||||
|
conn->ip = NULL;
|
||||||
|
|
||||||
if (conn->fd != -1) {
|
if (conn->fd != -1) {
|
||||||
res = CLOSE_SOCKET (conn->fd);
|
res = CLOSE_SOCKET (conn->fd);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
@ -1021,19 +1026,20 @@ sys_error:
|
||||||
RTSPResult
|
RTSPResult
|
||||||
rtsp_connection_free (RTSPConnection * conn)
|
rtsp_connection_free (RTSPConnection * conn)
|
||||||
{
|
{
|
||||||
|
RTSPResult res;
|
||||||
|
|
||||||
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
|
g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
#endif
|
#endif
|
||||||
|
res = rtsp_connection_close (conn);
|
||||||
g_timer_destroy (conn->timer);
|
g_timer_destroy (conn->timer);
|
||||||
g_free (conn->username);
|
g_free (conn->username);
|
||||||
g_free (conn->passwd);
|
g_free (conn->passwd);
|
||||||
|
|
||||||
g_free (conn);
|
g_free (conn);
|
||||||
|
|
||||||
return RTSP_OK;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
RTSPResult
|
RTSPResult
|
||||||
|
|
Loading…
Reference in a new issue