aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-service-rps.c')
-rw-r--r--src/rps/gnunet-service-rps.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 923540db0..4e9f795c3 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -379,7 +379,7 @@ static uint32_t num_mal_peers;
379/** 379/**
380 * If type is 2 this is the attacked peer 380 * If type is 2 this is the attacked peer
381 */ 381 */
382struct struct GNUNET_PeerIdentity attacked_peer; 382static struct GNUNET_PeerIdentity attacked_peer;
383#endif /* ENABLE_MALICIOUS */ 383#endif /* ENABLE_MALICIOUS */
384 384
385 385
@@ -1057,7 +1057,7 @@ handle_client_request (void *cls,
1057 msg = (struct GNUNET_RPS_CS_RequestMessage *) message; 1057 msg = (struct GNUNET_RPS_CS_RequestMessage *) message;
1058 1058
1059 num_peers = ntohl (msg->num_peers); 1059 num_peers = ntohl (msg->num_peers);
1060 size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) + 1060 size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) +
1061 num_peers * sizeof (struct GNUNET_PeerIdentity); 1061 num_peers * sizeof (struct GNUNET_PeerIdentity);
1062 1062
1063 if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) 1063 if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
@@ -1303,7 +1303,7 @@ handle_peer_pull_reply (void *cls,
1303 || NULL != peer_ctx->recv_channel) 1303 || NULL != peer_ctx->recv_channel)
1304 { 1304 {
1305 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i]) 1305 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])
1306 && GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i])) 1306 && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i]))
1307 GNUNET_array_append (pull_list, pull_list_size, peers[i]); 1307 GNUNET_array_append (pull_list, pull_list_size, peers[i]);
1308 } 1308 }
1309 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx)) 1309 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx))
@@ -1339,12 +1339,13 @@ handle_peer_act_malicious (void *cls,
1339 void **channel_ctx, 1339 void **channel_ctx,
1340 const struct GNUNET_MessageHeader *msg) 1340 const struct GNUNET_MessageHeader *msg)
1341{ 1341{
1342 struct GNUNET_RPS_CS_ActMaliciousMessage *in_msg;
1343 struct GNUNET_PeerIdentity *sender;
1344 struct PeerContext *sender_ctx;
1342 struct GNUNET_PeerIdentity *peers; 1345 struct GNUNET_PeerIdentity *peers;
1343 1346
1344 LOG (GNUNET_ERROR_TYPE_DEBUG, "PULL REPLY received\n");
1345
1346 /* Check for protocol violation */ 1347 /* Check for protocol violation */
1347 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size)) 1348 if (sizeof (struct GNUNET_RPS_CS_ActMaliciousMessage) > ntohs (msg->size))
1348 { 1349 {
1349 GNUNET_break_op (0); 1350 GNUNET_break_op (0);
1350 return GNUNET_SYSERR; 1351 return GNUNET_SYSERR;
@@ -1375,11 +1376,16 @@ handle_peer_act_malicious (void *cls,
1375 return GNUNET_OK; 1376 return GNUNET_OK;
1376 } 1377 }
1377 1378
1379
1378 /* Do actual logic */ 1380 /* Do actual logic */
1379 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 1381 peers = (struct GNUNET_PeerIdentity *) &msg[1];
1380 num_peers = ntohl (in_msg->num_peers); 1382 num_mal_peers = ntohl (in_msg->num_peers);
1381 mal_type = ntohl (in_msg->type); 1383 mal_type = ntohl (in_msg->type);
1382 1384
1385 LOG (GNUNET_ERROR_TYPE_DEBUG,
1386 "Now acting malicious type %" PRIX32 "\n",
1387 mal_type);
1388
1383 if (1 == mal_type) 1389 if (1 == mal_type)
1384 { /* Try to maximise representation */ 1390 { /* Try to maximise representation */
1385 num_mal_peers = ntohl (in_msg->num_peers); 1391 num_mal_peers = ntohl (in_msg->num_peers);
@@ -1395,6 +1401,8 @@ handle_peer_act_malicious (void *cls,
1395 memcpy (mal_peers, peers, num_mal_peers); 1401 memcpy (mal_peers, peers, num_mal_peers);
1396 attacked_peer = peers[num_mal_peers]; 1402 attacked_peer = peers[num_mal_peers];
1397 } 1403 }
1404
1405 return GNUNET_OK;
1398} 1406}
1399#endif /* ENABLE_MALICIOUS */ 1407#endif /* ENABLE_MALICIOUS */
1400 1408