summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-02-17 14:04:44 +0000
committerJulius Bünger <buenger@mytum.de>2015-02-17 14:04:44 +0000
commit0ea0ba9874d6252da26a2ae20090ffe095559cf9 (patch)
treecc4ed323066f9f5d63c0c2969fa11108537ab543 /src
parentb09e38d61b47755964855e572ee87ffe01848ceb (diff)
- fixed memory and coding issues
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 0ec80d3a4..3d61de21b 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1065,39 +1065,51 @@ handle_client_seed (void *cls,
{
struct GNUNET_RPS_CS_SeedMessage *in_msg;
struct GNUNET_PeerIdentity *peers;
+ uint32_t num_peers;
uint32_t i;
- if (sizeof (struct GNUNET_RPS_CS_SeedMessage) < ntohs (message->size))
+ if (sizeof (struct GNUNET_RPS_CS_SeedMessage) > ntohs (message->size))
{
GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
}
+
in_msg = (struct GNUNET_RPS_CS_SeedMessage *) message;
+ num_peers = ntohl (in_msg->num_peers);
+ peers = (struct GNUNET_PeerIdentity *) &in_msg[1];
+ //peers = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
+ //memcpy (peers, &in_msg[1], num_peers * sizeof (struct GNUNET_PeerIdentity));
+
if ((ntohs (message->size) - sizeof (struct GNUNET_RPS_CS_SeedMessage)) /
- sizeof (struct GNUNET_PeerIdentity) != ntohl (in_msg->num_peers))
+ sizeof (struct GNUNET_PeerIdentity) != num_peers)
{
GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
}
- in_msg = (struct GNUNET_RPS_CS_SeedMessage *) message;
- peers = (struct GNUNET_PeerIdentity *) &message[1];
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Client seeded peers:\n");
- print_peer_list (peers, ntohl (in_msg->num_peers));
+ print_peer_list (peers, num_peers);
+
+ // TODO check for validity of ids
- for ( i = 0 ; i < ntohl (in_msg->num_peers) ; i++ )
+ for (i = 0 ; i < num_peers ; i++)
+ {
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Updating samplers with seed %" PRIX32 ": %s\n",
+ i,
GNUNET_i2s (&peers[i]));
+
RPS_sampler_update (prot_sampler, &peers[i]);
RPS_sampler_update (client_sampler, &peers[i]);
+ }
+
+ //GNUNET_free (peers);
GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ GNUNET_OK);
}