aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 2a391e4d5..243425436 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1197,21 +1197,26 @@ handle_peer_pull_reply (void *cls,
1197 struct PeerOutstandingOp out_op; 1197 struct PeerOutstandingOp out_op;
1198 uint32_t i; 1198 uint32_t i;
1199 1199
1200 /* Check for protocol violation */
1200 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size)) 1201 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size))
1201 { 1202 {
1202 GNUNET_break_op (0); // At the moment our own implementation seems to break that. 1203 GNUNET_break_op (0);
1203 return GNUNET_SYSERR; 1204 return GNUNET_SYSERR;
1204 } 1205 }
1205 in_msg = (struct GNUNET_RPS_P2P_PullReplyMessage *) msg; 1206 in_msg = (struct GNUNET_RPS_P2P_PullReplyMessage *) msg;
1206 if ((ntohs (msg->size) - sizeof (struct GNUNET_RPS_P2P_PullReplyMessage)) / sizeof (struct GNUNET_PeerIdentity) != ntohl (in_msg->num_peers)) 1207 if ((ntohs (msg->size) - sizeof (struct GNUNET_RPS_P2P_PullReplyMessage)) /
1208 sizeof (struct GNUNET_PeerIdentity) != ntohl (in_msg->num_peers))
1207 { 1209 {
1208 LOG (GNUNET_ERROR_TYPE_ERROR, "message says it sends %" PRIu64 " peers, have space for %i peers\n", 1210 LOG (GNUNET_ERROR_TYPE_ERROR,
1211 "message says it sends %" PRIu64 " peers, have space for %i peers\n",
1209 ntohl (in_msg->num_peers), 1212 ntohl (in_msg->num_peers),
1210 (ntohs (msg->size) - sizeof (struct GNUNET_RPS_P2P_PullReplyMessage)) / sizeof (struct GNUNET_PeerIdentity)); 1213 (ntohs (msg->size) - sizeof (struct GNUNET_RPS_P2P_PullReplyMessage)) /
1214 sizeof (struct GNUNET_PeerIdentity));
1211 GNUNET_break_op (0); 1215 GNUNET_break_op (0);
1212 return GNUNET_SYSERR; 1216 return GNUNET_SYSERR;
1213 } 1217 }
1214 1218
1219 /* Do actual logic */
1215 sender = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info ( 1220 sender = (struct GNUNET_PeerIdentity *) GNUNET_CADET_channel_get_info (
1216 (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER); 1221 (struct GNUNET_CADET_Channel *) channel, GNUNET_CADET_OPTION_PEER);
1217 // Guess simply casting isn't the nicest way... 1222 // Guess simply casting isn't the nicest way...
@@ -1231,7 +1236,8 @@ handle_peer_pull_reply (void *cls,
1231 if (NULL != peer_ctx->send_channel 1236 if (NULL != peer_ctx->send_channel
1232 || NULL != peer_ctx->recv_channel) 1237 || NULL != peer_ctx->recv_channel)
1233 { 1238 {
1234 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])) 1239 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])
1240 && GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i]))
1235 GNUNET_array_append (pull_list, pull_list_size, peers[i]); 1241 GNUNET_array_append (pull_list, pull_list_size, peers[i]);
1236 } 1242 }
1237 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx)) 1243 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx))