[telepathy-gabble/master] socks5: check if the connection is actually connected when the target pretends it is
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Apr 3 09:26:06 PDT 2009
---
src/bytestream-socks5.c | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/bytestream-socks5.c b/src/bytestream-socks5.c
index 7b2fb7f..c7a5277 100644
--- a/src/bytestream-socks5.c
+++ b/src/bytestream-socks5.c
@@ -1263,6 +1263,14 @@ socks5_init_reply_cb (GabbleConnection *conn,
{
LmMessageNode *query, *streamhost = NULL;
+ if (priv->socks5_state != SOCKS5_STATE_CONNECTED)
+ {
+ DEBUG ("Target claims that the bytestream is open but SOCKS5 is not "
+ "connected (state: %u). Closing the bytestream",
+ priv->socks5_state);
+ goto socks5_init_error;
+ }
+
query = lm_message_node_get_child_with_namespace (reply_msg->node,
"query", NS_BYTESTREAMS);
@@ -1272,19 +1280,19 @@ socks5_init_reply_cb (GabbleConnection *conn,
if (streamhost == NULL)
{
DEBUG ("no streamhost-used has been defined. Closing the bytestream");
+ goto socks5_init_error;
}
- else
- {
- /* yeah, stream initiated */
- DEBUG ("Socks5 stream initiated using stream: %s",
- lm_message_node_get_attribute (streamhost, "jid"));
- g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_OPEN, NULL);
- /* We can read data from the sock5 socket now */
- gibber_transport_block_receiving (priv->transport, FALSE);
- return LM_HANDLER_RESULT_REMOVE_MESSAGE;
- }
+
+ /* yeah, stream initiated */
+ DEBUG ("Socks5 stream initiated using stream: %s",
+ lm_message_node_get_attribute (streamhost, "jid"));
+ g_object_set (self, "state", GABBLE_BYTESTREAM_STATE_OPEN, NULL);
+ /* We can read data from the sock5 socket now */
+ gibber_transport_block_receiving (priv->transport, FALSE);
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
}
+socks5_init_error:
DEBUG ("error during Socks5 initiation");
g_signal_emit_by_name (self, "connection-error");
--
1.5.6.5
More information about the telepathy-commits
mailing list