From def371c26f81180de9500c4e560a2d8d27d5d6ce Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 12 Feb 2014 12:01:31 +0000 Subject: fixing issues: - using uninitialized memory (mantis #3322) - notify only about new session created --- src/transport/plugin_transport_tcp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 09c410f2b..9665fe5c9 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -2038,6 +2038,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, const struct sockaddr_in6 *s6; struct GNUNET_ATS_Information ats; + if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity, sizeof(struct GNUNET_PeerIdentity))) { @@ -2054,6 +2055,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_break_op(0); return; } + LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", "WELCOME", GNUNET_i2s (&wm->clientIdentity), client); GNUNET_STATISTICS_update (plugin->env->stats, @@ -2105,20 +2107,26 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, ats = plugin->env->get_address_type (plugin->env->cls, vaddr, alen); session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl ( ats.value); - LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s'\n", - GNUNET_HELLO_address_check_option (session->address, GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "", - session, - tcp_address_to_string(NULL, (void *) session->address->address,session->address->address_length)); + LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s' client %p \n", + GNUNET_HELLO_address_check_option (session->address, + GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "", session, + tcp_address_to_string(NULL, (void *) session->address->address, + session->address->address_length), + client); GNUNET_free(vaddr); GNUNET_SERVER_client_set_user_context(session->client, session); GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, &session->target, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + + /* Notify transport and ATS about new session */ + plugin->env->session_start (NULL, session->address, session, &ats, 1); } else { LOG(GNUNET_ERROR_TYPE_DEBUG, "Did not obtain TCP socket address for incoming connection\n"); GNUNET_break(0); + return; } } @@ -2132,9 +2140,6 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, session->last_activity = GNUNET_TIME_absolute_get (); session->expecting_welcome = GNUNET_NO; - /* Notify transport and ATS about new session */ - plugin->env->session_start (NULL, session->address, session, &ats, 1); - process_pending_messages (session); GNUNET_SERVER_client_set_timeout (client, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); -- cgit v1.2.3