diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-12 12:01:31 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-12 12:01:31 +0000 |
commit | def371c26f81180de9500c4e560a2d8d27d5d6ce (patch) | |
tree | 6536e8eaecd79abb7a5ea3567480167202e352bd /src | |
parent | 908cca82ad1dcd1c5bea62cfb8526e66a1226540 (diff) | |
download | gnunet-def371c26f81180de9500c4e560a2d8d27d5d6ce.tar.gz gnunet-def371c26f81180de9500c4e560a2d8d27d5d6ce.zip |
fixing issues:
- using uninitialized memory (mantis #3322)
- notify only about new session created
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 19 |
1 files changed, 12 insertions, 7 deletions
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, | |||
2038 | const struct sockaddr_in6 *s6; | 2038 | const struct sockaddr_in6 *s6; |
2039 | struct GNUNET_ATS_Information ats; | 2039 | struct GNUNET_ATS_Information ats; |
2040 | 2040 | ||
2041 | |||
2041 | if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity, | 2042 | if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity, |
2042 | sizeof(struct GNUNET_PeerIdentity))) | 2043 | sizeof(struct GNUNET_PeerIdentity))) |
2043 | { | 2044 | { |
@@ -2054,6 +2055,7 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
2054 | GNUNET_break_op(0); | 2055 | GNUNET_break_op(0); |
2055 | return; | 2056 | return; |
2056 | } | 2057 | } |
2058 | |||
2057 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", "WELCOME", | 2059 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", "WELCOME", |
2058 | GNUNET_i2s (&wm->clientIdentity), client); | 2060 | GNUNET_i2s (&wm->clientIdentity), client); |
2059 | GNUNET_STATISTICS_update (plugin->env->stats, | 2061 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -2105,20 +2107,26 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
2105 | ats = plugin->env->get_address_type (plugin->env->cls, vaddr, alen); | 2107 | ats = plugin->env->get_address_type (plugin->env->cls, vaddr, alen); |
2106 | session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl ( | 2108 | session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl ( |
2107 | ats.value); | 2109 | ats.value); |
2108 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s'\n", | 2110 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s' client %p \n", |
2109 | GNUNET_HELLO_address_check_option (session->address, GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "", | 2111 | GNUNET_HELLO_address_check_option (session->address, |
2110 | session, | 2112 | GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "", session, |
2111 | tcp_address_to_string(NULL, (void *) session->address->address,session->address->address_length)); | 2113 | tcp_address_to_string(NULL, (void *) session->address->address, |
2114 | session->address->address_length), | ||
2115 | client); | ||
2112 | GNUNET_free(vaddr); | 2116 | GNUNET_free(vaddr); |
2113 | GNUNET_SERVER_client_set_user_context(session->client, session); | 2117 | GNUNET_SERVER_client_set_user_context(session->client, session); |
2114 | GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, &session->target, | 2118 | GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, &session->target, |
2115 | session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2119 | session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2120 | |||
2121 | /* Notify transport and ATS about new session */ | ||
2122 | plugin->env->session_start (NULL, session->address, session, &ats, 1); | ||
2116 | } | 2123 | } |
2117 | else | 2124 | else |
2118 | { | 2125 | { |
2119 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2126 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2120 | "Did not obtain TCP socket address for incoming connection\n"); | 2127 | "Did not obtain TCP socket address for incoming connection\n"); |
2121 | GNUNET_break(0); | 2128 | GNUNET_break(0); |
2129 | return; | ||
2122 | } | 2130 | } |
2123 | } | 2131 | } |
2124 | 2132 | ||
@@ -2132,9 +2140,6 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
2132 | session->last_activity = GNUNET_TIME_absolute_get (); | 2140 | session->last_activity = GNUNET_TIME_absolute_get (); |
2133 | session->expecting_welcome = GNUNET_NO; | 2141 | session->expecting_welcome = GNUNET_NO; |
2134 | 2142 | ||
2135 | /* Notify transport and ATS about new session */ | ||
2136 | plugin->env->session_start (NULL, session->address, session, &ats, 1); | ||
2137 | |||
2138 | process_pending_messages (session); | 2143 | process_pending_messages (session); |
2139 | GNUNET_SERVER_client_set_timeout (client, | 2144 | GNUNET_SERVER_client_set_timeout (client, |
2140 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 2145 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |