mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Clear proxy address upon retry
The proxy address was not cleared between each attempt. That would lead to leak or worse, trying to do the proxy handshake on the final destination address. To make all this safer, I have regroup all the cleanup where the iterations starts. https://bugzilla.gnome.org/show_bug.cgi?id=664141
This commit is contained in:
parent
216fd8a82c
commit
4ae42ceb3c
@ -1172,6 +1172,12 @@ set_last_error (GSocketClientAsyncConnectData *data,
|
|||||||
static void
|
static void
|
||||||
enumerator_next_async (GSocketClientAsyncConnectData *data)
|
enumerator_next_async (GSocketClientAsyncConnectData *data)
|
||||||
{
|
{
|
||||||
|
/* We need to cleanup the state */
|
||||||
|
g_clear_object (&data->current_socket);
|
||||||
|
g_clear_object (&data->current_addr);
|
||||||
|
g_clear_object (&data->proxy_addr);
|
||||||
|
g_clear_object (&data->connection);
|
||||||
|
|
||||||
g_socket_address_enumerator_next_async (data->enumerator,
|
g_socket_address_enumerator_next_async (data->enumerator,
|
||||||
data->cancellable,
|
data->cancellable,
|
||||||
g_socket_client_enumerator_callback,
|
g_socket_client_enumerator_callback,
|
||||||
@ -1197,11 +1203,6 @@ g_socket_client_tls_handshake_callback (GObject *object,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_object_unref (object);
|
g_object_unref (object);
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
g_object_unref (data->connection);
|
|
||||||
data->connection = NULL;
|
|
||||||
|
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1232,11 +1233,6 @@ g_socket_client_tls_handshake (GSocketClientAsyncConnectData *data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
g_object_unref (data->connection);
|
|
||||||
data->connection = NULL;
|
|
||||||
|
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1254,9 +1250,6 @@ g_socket_client_proxy_connect_callback (GObject *object,
|
|||||||
&data->last_error);
|
&data->last_error);
|
||||||
if (!data->connection)
|
if (!data->connection)
|
||||||
{
|
{
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
|
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1291,11 +1284,6 @@ g_socket_client_proxy_connect (GSocketClientAsyncConnectData *data)
|
|||||||
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
_("Trying to proxy over non-TCP connection is not supported."));
|
_("Trying to proxy over non-TCP connection is not supported."));
|
||||||
|
|
||||||
g_object_unref (data->connection);
|
|
||||||
data->connection = NULL;
|
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
|
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
}
|
}
|
||||||
else if (proxy)
|
else if (proxy)
|
||||||
@ -1317,13 +1305,6 @@ g_socket_client_proxy_connect (GSocketClientAsyncConnectData *data)
|
|||||||
_("Proxy protocol '%s' is not supported."),
|
_("Proxy protocol '%s' is not supported."),
|
||||||
protocol);
|
protocol);
|
||||||
|
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
g_object_unref (data->connection);
|
|
||||||
data->connection = NULL;
|
|
||||||
g_object_unref (data->current_socket);
|
|
||||||
data->current_socket = NULL;
|
|
||||||
|
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1350,8 +1331,6 @@ g_socket_client_socket_callback (GSocket *socket,
|
|||||||
{
|
{
|
||||||
/* Cancelled, return done with last error being cancelled */
|
/* Cancelled, return done with last error being cancelled */
|
||||||
g_clear_error (&data->last_error);
|
g_clear_error (&data->last_error);
|
||||||
g_clear_object (&data->current_socket);
|
|
||||||
g_clear_object (&data->current_addr);
|
|
||||||
g_cancellable_set_error_if_cancelled (data->cancellable,
|
g_cancellable_set_error_if_cancelled (data->cancellable,
|
||||||
&data->last_error);
|
&data->last_error);
|
||||||
|
|
||||||
@ -1365,10 +1344,7 @@ g_socket_client_socket_callback (GSocket *socket,
|
|||||||
{
|
{
|
||||||
clarify_connect_error (error, data->connectable,
|
clarify_connect_error (error, data->connectable,
|
||||||
data->current_addr);
|
data->current_addr);
|
||||||
|
|
||||||
set_last_error (data, error);
|
set_last_error (data, error);
|
||||||
g_clear_object (&data->current_socket);
|
|
||||||
g_clear_object (&data->current_addr);
|
|
||||||
|
|
||||||
/* try next one */
|
/* try next one */
|
||||||
enumerator_next_async (data);
|
enumerator_next_async (data);
|
||||||
|
Loading…
Reference in New Issue
Block a user