- fix coverity 10087
authorBart Polot <bart@net.in.tum.de>
Mon, 23 Jul 2012 13:42:55 +0000 (13:42 +0000)
committerBart Polot <bart@net.in.tum.de>
Mon, 23 Jul 2012 13:42:55 +0000 (13:42 +0000)
src/mesh/mesh_api.c

index da88e430767372b48cda10d1df99bae28a368304..f29ebe9d21b76eb9f9390e7e0f46157b88041cb1 100644 (file)
@@ -1695,20 +1695,24 @@ void
 GNUNET_MESH_peer_request_connect_by_string (struct GNUNET_MESH_Tunnel *tunnel,
                                             const char *description)
 {
-  struct GNUNET_MESH_ConnectPeerByString *msg;
+  struct GNUNET_MESH_ConnectPeerByString *m;
   size_t len;
   size_t msgsize;
 
-  len = strlen(description);
+  len = strlen (description);
   msgsize = sizeof(struct GNUNET_MESH_ConnectPeerByString) + len;
   GNUNET_assert (UINT16_MAX > msgsize);
-  msg = GNUNET_malloc (msgsize);
-  msg->header.size = htons (msgsize);
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING);
-  msg->tunnel_id = htonl (tunnel->tid);
-  memcpy(&msg[1], description, len);
+  {
+    char buffer[msgsize];
 
-  send_packet (tunnel->mesh, &msg->header, tunnel);
+    m = (struct GNUNET_MESH_ConnectPeerByString *) buffer;
+    m->header.size = htons (msgsize);
+    m->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING);
+    m->tunnel_id = htonl (tunnel->tid);
+    memcpy(&m[1], description, len);
+
+    send_packet (tunnel->mesh, &m->header, tunnel);
+  }
 }