summaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-10-28 11:36:16 +0000
committerBart Polot <bart@net.in.tum.de>2011-10-28 11:36:16 +0000
commitbbbce5ff82754dde929f3a9379245a1ca4089f66 (patch)
tree4f87202ad03be31a98823d32f778c058a39819b2 /src/mesh
parent20bb6e2908d9991a716d751563b9b45cf79961f6 (diff)
Fixed coverity #10227, added doxygen to avoid bug again.
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 59c5174ac..6e0af467b 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1130,7 +1130,7 @@ send_core_data_raw (void *cls, size_t size, void *buf)
* 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 @@ send_create_path (struct MeshPeerInfo *peer,
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 @@ send_destroy_path (struct MeshTunnel *t, GNUNET_PEER_Id destination)
}
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);
}