From 29cf3c9a615e5af2192a10055988434bc5abbe41 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Fri, 2 Jul 2010 16:02:28 +0000 Subject: [PATCH] codesonar fixes, hopefully doesn't break anything --- src/dht/dht_api.c | 13 +++---------- src/dht/gnunet-service-dht.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 7095eeb6d..a6fefd59a 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c @@ -348,12 +348,11 @@ finish (struct GNUNET_DHT_Handle *handle, int code) { struct PendingMessage *pos = handle->current; GNUNET_HashCode uid_hash; - hash_from_uid (pos->unique_id, &uid_hash); #if DEBUG_DHT_API GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s': Finish called!\n", "DHT API"); #endif GNUNET_assert (pos != NULL); - + hash_from_uid (pos->unique_id, &uid_hash); if (pos->cont != NULL) { if (code == GNUNET_SYSERR) @@ -792,7 +791,6 @@ find_peer_reply_iterator (void *cls, const struct GNUNET_MessageHeader *reply) { struct GNUNET_DHT_FindPeerHandle *find_peer_handle = cls; struct GNUNET_MessageHeader *hello; - size_t hello_size; if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT) { @@ -804,7 +802,6 @@ find_peer_reply_iterator (void *cls, const struct GNUNET_MessageHeader *reply) GNUNET_assert (ntohs (reply->size) >= sizeof (struct GNUNET_MessageHeader)); - hello_size = ntohs(reply->size) - sizeof(struct GNUNET_MessageHeader); hello = (struct GNUNET_MessageHeader *)&reply[1]; if (ntohs(hello->type) != GNUNET_MESSAGE_TYPE_HELLO) @@ -879,10 +876,6 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, &uid_key, route_handle, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } - else - { - route_handle->uid = 0; - } #if DEBUG_DHT_API GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -909,7 +902,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, handle->current = pending; process_pending_message (handle); } - else if ((handle->current != NULL) && (handle->retransmit_stage == DHT_RETRANSMITTING)) + else if (handle->retransmit_stage == DHT_RETRANSMITTING) { handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; handle->retransmission_buffer = pending; @@ -1009,7 +1002,7 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle, route_handle->dht_handle->current = pending; process_pending_message (route_handle->dht_handle); } - else if ((route_handle->dht_handle->current != NULL) && (route_handle->dht_handle->retransmit_stage == DHT_RETRANSMITTING)) + else if (route_handle->dht_handle->retransmit_stage == DHT_RETRANSMITTING) { route_handle->dht_handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; route_handle->dht_handle->retransmission_buffer = pending; diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index e64b9a1ea..a310cc944 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -42,7 +42,7 @@ /** * Handle to the datacache service (for inserting/retrieving data) */ -struct GNUNET_DATACACHE_Handle *datacache; +static struct GNUNET_DATACACHE_Handle *datacache; /** * The main scheduler to use for the DHT service @@ -443,7 +443,12 @@ handle_dht_find_peer (void *cls, /* Simplistic find_peer functionality, always return our hello */ hello_size = ntohs(my_hello->size); tsize = hello_size + sizeof (struct GNUNET_MessageHeader); - // check tsize < MAX + + if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) + { + GNUNET_break_op (0); + return; + } find_peer_result = GNUNET_malloc (tsize); find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT); find_peer_result->size = htons (tsize); @@ -604,7 +609,7 @@ handle_dht_start_message (void *cls, struct GNUNET_SERVER_Client *client, * @param client the client we received this message from * @param message the actual message received * - * TODO: once message are remembered by unique id, add code to + * TODO: once messages are remembered by unique id, add code to * forget them here */ static void @@ -800,6 +805,8 @@ void handle_core_connect (void *cls, "%s Inserting data %s, type %d into datacache, return value was %d\n", my_short_id, GNUNET_h2s(&peer->hashPubKey), 130, ret); #endif } + else + GNUNET_free(data); } /** -- 2.25.1