diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-16 15:21:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-16 15:21:40 +0000 |
commit | c90957f078692b28d99b330a485a3f2becfa89bb (patch) | |
tree | 83729dd2d728fdd1a07ac66d3c6ee45e2b02cb80 /src/dht/gnunet-service-dht.c | |
parent | c225a6588b0d3aa95ad3f55a8f27aab33130b0e7 (diff) | |
download | gnunet-c90957f078692b28d99b330a485a3f2becfa89bb.tar.gz gnunet-c90957f078692b28d99b330a485a3f2becfa89bb.zip |
fixing FIXME, major bug with dangling pointer, c3142
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index b58fa7ede..53487f4be 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -369,9 +369,8 @@ struct DHT_MessageContext | |||
369 | 369 | ||
370 | /** | 370 | /** |
371 | * The peer this request was received from. | 371 | * The peer this request was received from. |
372 | * (NULL if received from local client) | ||
373 | */ | 372 | */ |
374 | const struct GNUNET_PeerIdentity *peer; | 373 | struct GNUNET_PeerIdentity peer; |
375 | 374 | ||
376 | /** | 375 | /** |
377 | * Bloomfilter for this routing request. | 376 | * Bloomfilter for this routing request. |
@@ -1918,7 +1917,7 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
1918 | { | 1917 | { |
1919 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, | 1918 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
1920 | msg_ctx->hop_count, GNUNET_SYSERR, | 1919 | msg_ctx->hop_count, GNUNET_SYSERR, |
1921 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 1920 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
1922 | NULL); | 1921 | NULL); |
1923 | } | 1922 | } |
1924 | #endif | 1923 | #endif |
@@ -1963,7 +1962,7 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
1963 | { | 1962 | { |
1964 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, | 1963 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
1965 | msg_ctx->hop_count, GNUNET_YES, | 1964 | msg_ctx->hop_count, GNUNET_YES, |
1966 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 1965 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
1967 | NULL); | 1966 | NULL); |
1968 | } | 1967 | } |
1969 | #endif | 1968 | #endif |
@@ -2016,7 +2015,7 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2016 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, | 2015 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
2017 | msg_ctx->hop_count, GNUNET_NO, | 2016 | msg_ctx->hop_count, GNUNET_NO, |
2018 | &my_identity, &msg_ctx->key, | 2017 | &my_identity, &msg_ctx->key, |
2019 | msg_ctx->peer, &pos->source); | 2018 | &msg_ctx->peer, &pos->source); |
2020 | } | 2019 | } |
2021 | #endif | 2020 | #endif |
2022 | forward_result_message (msg, peer_info, msg_ctx); | 2021 | forward_result_message (msg, peer_info, msg_ctx); |
@@ -2157,7 +2156,7 @@ datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | |||
2157 | memcpy (&get_result[1], &put_entry[1], | 2156 | memcpy (&get_result[1], &put_entry[1], |
2158 | put_entry->data_size + | 2157 | put_entry->data_size + |
2159 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity))); | 2158 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity))); |
2160 | new_msg_ctx.peer = &my_identity; | 2159 | new_msg_ctx.peer = my_identity; |
2161 | new_msg_ctx.bloom = NULL; | 2160 | new_msg_ctx.bloom = NULL; |
2162 | new_msg_ctx.hop_count = 0; | 2161 | new_msg_ctx.hop_count = 0; |
2163 | new_msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ | 2162 | new_msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ |
@@ -2310,7 +2309,7 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2310 | { | 2309 | { |
2311 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2310 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2312 | msg_ctx->hop_count, GNUNET_YES, &my_identity, | 2311 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2313 | &msg_ctx->key, msg_ctx->peer, NULL); | 2312 | &msg_ctx->key, &msg_ctx->peer, NULL); |
2314 | } | 2313 | } |
2315 | #endif | 2314 | #endif |
2316 | } | 2315 | } |
@@ -2533,7 +2532,7 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2533 | 2532 | ||
2534 | new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); | 2533 | new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); |
2535 | memcpy (new_msg_ctx, msg_ctx, sizeof (struct DHT_MessageContext)); | 2534 | memcpy (new_msg_ctx, msg_ctx, sizeof (struct DHT_MessageContext)); |
2536 | new_msg_ctx->peer = &my_identity; | 2535 | new_msg_ctx->peer = my_identity; |
2537 | new_msg_ctx->bloom = | 2536 | new_msg_ctx->bloom = |
2538 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 2537 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
2539 | new_msg_ctx->hop_count = 0; | 2538 | new_msg_ctx->hop_count = 0; |
@@ -2616,7 +2615,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2616 | { | 2615 | { |
2617 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2616 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2618 | msg_ctx->hop_count, GNUNET_SYSERR, | 2617 | msg_ctx->hop_count, GNUNET_SYSERR, |
2619 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 2618 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
2620 | NULL); | 2619 | NULL); |
2621 | } | 2620 | } |
2622 | #endif | 2621 | #endif |
@@ -2632,7 +2631,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2632 | { | 2631 | { |
2633 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2632 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2634 | msg_ctx->hop_count, GNUNET_SYSERR, | 2633 | msg_ctx->hop_count, GNUNET_SYSERR, |
2635 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 2634 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
2636 | NULL); | 2635 | NULL); |
2637 | } | 2636 | } |
2638 | #endif | 2637 | #endif |
@@ -2715,7 +2714,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2715 | path_offset += data_size; | 2714 | path_offset += data_size; |
2716 | memcpy (path_offset, msg_ctx->path_history, | 2715 | memcpy (path_offset, msg_ctx->path_history, |
2717 | msg_ctx->path_history_len * sizeof (struct GNUNET_PeerIdentity)); | 2716 | msg_ctx->path_history_len * sizeof (struct GNUNET_PeerIdentity)); |
2718 | new_msg_ctx.peer = &my_identity; | 2717 | new_msg_ctx.peer = my_identity; |
2719 | new_msg_ctx.bloom = NULL; | 2718 | new_msg_ctx.bloom = NULL; |
2720 | new_msg_ctx.hop_count = 0; | 2719 | new_msg_ctx.hop_count = 0; |
2721 | /* Make result routing a higher priority */ | 2720 | /* Make result routing a higher priority */ |
@@ -2746,7 +2745,7 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2746 | { | 2745 | { |
2747 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2746 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2748 | msg_ctx->hop_count, GNUNET_YES, &my_identity, | 2747 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2749 | &msg_ctx->key, msg_ctx->peer, NULL); | 2748 | &msg_ctx->key, &msg_ctx->peer, NULL); |
2750 | } | 2749 | } |
2751 | 2750 | ||
2752 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2751 | if ((debug_routes) && (dhtlog_handle != NULL)) |
@@ -3142,11 +3141,10 @@ cache_response (struct DHT_MessageContext *msg_ctx) | |||
3142 | pos = record->head; | 3141 | pos = record->head; |
3143 | while (pos != NULL) | 3142 | while (pos != NULL) |
3144 | { | 3143 | { |
3145 | if ((NULL != msg_ctx->peer) && | 3144 | if (0 == |
3146 | (0 == | 3145 | memcmp (&msg_ctx->peer, &pos->source, |
3147 | memcmp (msg_ctx->peer, &pos->source, | 3146 | sizeof (struct GNUNET_PeerIdentity))) |
3148 | sizeof (struct GNUNET_PeerIdentity)))) | 3147 | break; /* Already have this peer in reply list! */ |
3149 | break; /* Already have this peer in reply list! */ | ||
3150 | pos = pos->next; | 3148 | pos = pos->next; |
3151 | } | 3149 | } |
3152 | if ((pos != NULL) && (pos->client == msg_ctx->client)) /* Seen this already */ | 3150 | if ((pos != NULL) && (pos->client == msg_ctx->client)) /* Seen this already */ |
@@ -3173,7 +3171,7 @@ cache_response (struct DHT_MessageContext *msg_ctx) | |||
3173 | source_info); | 3171 | source_info); |
3174 | source_info->find_peers_responded = | 3172 | source_info->find_peers_responded = |
3175 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3173 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3176 | source_info->source = *msg_ctx->peer; | 3174 | source_info->source = msg_ctx->peer; |
3177 | GNUNET_CONTAINER_DLL_insert_after (record->head, record->tail, record->tail, | 3175 | GNUNET_CONTAINER_DLL_insert_after (record->head, record->tail, record->tail, |
3178 | source_info); | 3176 | source_info); |
3179 | if (msg_ctx->client != NULL) /* For local request, set timeout so high it effectively never gets pushed out */ | 3177 | if (msg_ctx->client != NULL) /* For local request, set timeout so high it effectively never gets pushed out */ |
@@ -3230,7 +3228,7 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3230 | { | 3228 | { |
3231 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3229 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3232 | msg_ctx->hop_count, GNUNET_SYSERR, | 3230 | msg_ctx->hop_count, GNUNET_SYSERR, |
3233 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 3231 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
3234 | NULL); | 3232 | NULL); |
3235 | } | 3233 | } |
3236 | #endif | 3234 | #endif |
@@ -3365,7 +3363,7 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3365 | { | 3363 | { |
3366 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3364 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3367 | msg_ctx->hop_count, GNUNET_NO, | 3365 | msg_ctx->hop_count, GNUNET_NO, |
3368 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 3366 | &my_identity, &msg_ctx->key, &msg_ctx->peer, |
3369 | &selected->id); | 3367 | &selected->id); |
3370 | } | 3368 | } |
3371 | #endif | 3369 | #endif |
@@ -3391,7 +3389,7 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3391 | { | 3389 | { |
3392 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3390 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3393 | msg_ctx->hop_count, ret, &my_identity, | 3391 | msg_ctx->hop_count, ret, &my_identity, |
3394 | &msg_ctx->key, msg_ctx->peer, NULL); | 3392 | &msg_ctx->key, &msg_ctx->peer, NULL); |
3395 | } | 3393 | } |
3396 | #endif | 3394 | #endif |
3397 | } | 3395 | } |
@@ -3425,7 +3423,7 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, | |||
3425 | increment_stats (STAT_FIND_PEER); | 3423 | increment_stats (STAT_FIND_PEER); |
3426 | if (((msg_ctx->hop_count > 0) && | 3424 | if (((msg_ctx->hop_count > 0) && |
3427 | (0 != | 3425 | (0 != |
3428 | memcmp (msg_ctx->peer, &my_identity, | 3426 | memcmp (&msg_ctx->peer, &my_identity, |
3429 | sizeof (struct GNUNET_PeerIdentity)))) || | 3427 | sizeof (struct GNUNET_PeerIdentity)))) || |
3430 | (msg_ctx->client != NULL)) | 3428 | (msg_ctx->client != NULL)) |
3431 | { | 3429 | { |
@@ -3767,7 +3765,7 @@ send_find_peer_message (void *cls, | |||
3767 | msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; | 3765 | msg_ctx.replication = DHT_DEFAULT_FIND_PEER_REPLICATION; |
3768 | msg_ctx.msg_options = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; | 3766 | msg_ctx.msg_options = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; |
3769 | msg_ctx.network_size = log_of_network_size_estimate; | 3767 | msg_ctx.network_size = log_of_network_size_estimate; |
3770 | msg_ctx.peer = &my_identity; | 3768 | msg_ctx.peer = my_identity; |
3771 | msg_ctx.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; | 3769 | msg_ctx.importance = DHT_DEFAULT_FIND_PEER_IMPORTANCE; |
3772 | msg_ctx.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; | 3770 | msg_ctx.timeout = DHT_DEFAULT_FIND_PEER_TIMEOUT; |
3773 | 3771 | ||
@@ -3848,7 +3846,7 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
3848 | msg_ctx.path_history_len = 1; | 3846 | msg_ctx.path_history_len = 1; |
3849 | } | 3847 | } |
3850 | msg_ctx.network_size = log_of_network_size_estimate; | 3848 | msg_ctx.network_size = log_of_network_size_estimate; |
3851 | msg_ctx.peer = &my_identity; /* FIXME: use NULL? Fix doxygen? */ | 3849 | msg_ctx.peer = my_identity; |
3852 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ | 3850 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 4; /* Make local routing a higher priority */ |
3853 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 3851 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
3854 | 3852 | ||
@@ -4120,7 +4118,7 @@ handle_dht_p2p_route_request (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4120 | msg_ctx->path_history_len = ntohl (incoming->outgoing_path_length) + 1; | 4118 | msg_ctx->path_history_len = ntohl (incoming->outgoing_path_length) + 1; |
4121 | } | 4119 | } |
4122 | msg_ctx->network_size = ntohl (incoming->network_size); | 4120 | msg_ctx->network_size = ntohl (incoming->network_size); |
4123 | msg_ctx->peer = peer; | 4121 | msg_ctx->peer = *peer; |
4124 | msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE; | 4122 | msg_ctx->importance = DHT_DEFAULT_P2P_IMPORTANCE; |
4125 | msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4123 | msg_ctx->timeout = DHT_DEFAULT_P2P_TIMEOUT; |
4126 | demultiplex_message (enc_msg, msg_ctx); | 4124 | demultiplex_message (enc_msg, msg_ctx); |
@@ -4190,7 +4188,7 @@ handle_dht_p2p_route_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4190 | msg_ctx.unique_id = GNUNET_ntohll (incoming->unique_id); | 4188 | msg_ctx.unique_id = GNUNET_ntohll (incoming->unique_id); |
4191 | msg_ctx.msg_options = ntohl (incoming->options); | 4189 | msg_ctx.msg_options = ntohl (incoming->options); |
4192 | msg_ctx.hop_count = ntohl (incoming->hop_count); | 4190 | msg_ctx.hop_count = ntohl (incoming->hop_count); |
4193 | msg_ctx.peer = peer; | 4191 | msg_ctx.peer = *peer; |
4194 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ | 4192 | msg_ctx.importance = DHT_DEFAULT_P2P_IMPORTANCE + 2; /* Make result routing a higher priority */ |
4195 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; | 4193 | msg_ctx.timeout = DHT_DEFAULT_P2P_TIMEOUT; |
4196 | if ((GNUNET_DHT_RO_RECORD_ROUTE == | 4194 | if ((GNUNET_DHT_RO_RECORD_ROUTE == |