codesonar fixes, hopefully doesn't break anything
authorNathan S. Evans <evans@in.tum.de>
Fri, 2 Jul 2010 16:02:28 +0000 (16:02 +0000)
committerNathan S. Evans <evans@in.tum.de>
Fri, 2 Jul 2010 16:02:28 +0000 (16:02 +0000)
src/dht/dht_api.c
src/dht/gnunet-service-dht.c

index 7095eeb6d364c5ee0ff5034b84c07f6e79f63e21..a6fefd59a6353ce7c55364e1f6f6a183c96dfafe 100644 (file)
@@ -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;
index e64b9a1ea7408eb2dc2dbac9a0ba3cfb18dd52ca..a310cc9449c55ce745d963961ea70c900b9988bc 100644 (file)
@@ -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);
 }
 
 /**