gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r17837 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r17837 - gnunet/src/mesh
Date: Fri, 28 Oct 2011 13:36:16 +0200

Author: bartpolot
Date: 2011-10-28 13:36:16 +0200 (Fri, 28 Oct 2011)
New Revision: 17837

Modified:
   gnunet/src/mesh/gnunet-service-mesh.c
Log:
Fixed coverity #10227, added doxygen to avoid bug again.

Modified: gnunet/src/mesh/gnunet-service-mesh.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh.c       2011-10-28 11:17:35 UTC (rev 
17836)
+++ gnunet/src/mesh/gnunet-service-mesh.c       2011-10-28 11:36:16 UTC (rev 
17837)
@@ -1130,7 +1130,7 @@
  * Sends an already built message to a peer, properly registrating
  * all used resources.
  *
- * @param message Message to send.
+ * @param message Message to send. Fucntion makes a copy of it.
  * @param peer Short ID of the neighbor whom to send the message.
  */
 static void
@@ -1236,10 +1236,7 @@
 static void
 send_destroy_path (struct MeshTunnel *t, GNUNET_PEER_Id destination)
 {
-  struct GNUNET_MESH_ManipulatePath *msg;
-  struct GNUNET_PeerIdentity *pi;
   struct MeshPeerPath *p;
-  unsigned int i;
   size_t size;
 
   p = tree_get_path_to_peer(t->tree, destination);
@@ -1250,16 +1247,23 @@
   }
   size = sizeof (struct GNUNET_MESH_ManipulatePath);
   size += p->length * sizeof (struct GNUNET_PeerIdentity);
-  msg = GNUNET_malloc (size);
-  msg->header.size = htons (size);
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY);
-  msg->tid = htonl (t->id.tid);
-  pi = (struct GNUNET_PeerIdentity *) &msg[1];
-  for (i = 0; i < p->length; i++)
   {
-    GNUNET_PEER_resolve(p->peers[i], &pi[i]);
+    struct GNUNET_MESH_ManipulatePath *msg;
+    struct GNUNET_PeerIdentity *pi;
+    char cbuf[size];
+    unsigned int i;
+
+    msg = (struct GNUNET_MESH_ManipulatePath *) cbuf;
+    msg->header.size = htons (size);
+    msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY);
+    msg->tid = htonl (t->id.tid);
+    pi = (struct GNUNET_PeerIdentity *) &msg[1];
+    for (i = 0; i < p->length; i++)
+    {
+      GNUNET_PEER_resolve(p->peers[i], &pi[i]);
+    }
+    send_message (&msg->header, path_get_first_hop(t->tree, destination));
   }
-  send_message (&msg->header, path_get_first_hop(t->tree, destination));
   path_destroy (p);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]