aboutsummaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-03-18 11:49:52 +0000
committerChristian Grothoff <christian@grothoff.org>2013-03-18 11:49:52 +0000
commitef4bd8de47b45e808d29a8f5ee3d1c4f15c96353 (patch)
treeb496042c0e2a73378cc4e73beb71299bfd32b350 /src/consensus
parent3ed1a0a351ef02182504649afcb18d51277e6da5 (diff)
downloadgnunet-ef4bd8de47b45e808d29a8f5ee3d1c4f15c96353.tar.gz
gnunet-ef4bd8de47b45e808d29a8f5ee3d1c4f15c96353.zip
-fix uninitialized sendto
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/consensus.h23
-rw-r--r--src/consensus/consensus_api.c11
-rw-r--r--src/consensus/gnunet-service-consensus.c6
3 files changed, 19 insertions, 21 deletions
diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h
index 8436364b6..2c68849b9 100644
--- a/src/consensus/consensus.h
+++ b/src/consensus/consensus.h
@@ -37,9 +37,9 @@ struct GNUNET_CONSENSUS_JoinMessage
37 */ 37 */
38 struct GNUNET_MessageHeader header; 38 struct GNUNET_MessageHeader header;
39 39
40 struct GNUNET_HashCode session_id; 40 uint32_t num_peers GNUNET_PACKED;
41 41
42 uint16_t num_peers; 42 struct GNUNET_HashCode session_id;
43 43
44 /* GNUNET_PeerIdentity[num_peers] */ 44 /* GNUNET_PeerIdentity[num_peers] */
45}; 45};
@@ -52,15 +52,16 @@ struct GNUNET_CONSENSUS_ConcludeMessage
52 */ 52 */
53 struct GNUNET_MessageHeader header; 53 struct GNUNET_MessageHeader header;
54 54
55
55 /** 56 /**
56 * Timeout for conclude 57 * Minimum group size required for a consensus group.
57 */ 58 */
58 struct GNUNET_TIME_RelativeNBO timeout; 59 uint32_t min_group_size GNUNET_PACKED;
59 60
60 /** 61 /**
61 * Minimum group size required for a consensus group. 62 * Timeout for conclude
62 */ 63 */
63 uint32_t min_group_size; 64 struct GNUNET_TIME_RelativeNBO timeout;
64}; 65};
65 66
66 67
@@ -71,11 +72,11 @@ struct GNUNET_CONSENSUS_ConcludeDoneMessage
71 */ 72 */
72 struct GNUNET_MessageHeader header; 73 struct GNUNET_MessageHeader header;
73 74
74 uint32_t group_id; 75 uint32_t group_id GNUNET_PACKED;
75 76
76 uint32_t num_elements; 77 uint32_t num_elements GNUNET_PACKED;
77 78
78 uint16_t num_peers; 79 uint32_t num_peers GNUNET_PACKED;
79 80
80 /** PeerIdentity[num_peers] */ 81 /** PeerIdentity[num_peers] */
81}; 82};
@@ -97,7 +98,7 @@ struct GNUNET_CONSENSUS_ElementMessage
97 /** 98 /**
98 * Type: GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_NEW_ELEMENT 99 * Type: GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_NEW_ELEMENT
99 */ 100 */
100 uint16_t element_type; 101 uint16_t element_type GNUNET_PACKED; /* FIXME: alignment? */
101 102
102 /* rest: element data */ 103 /* rest: element data */
103}; 104};
@@ -112,7 +113,7 @@ struct GNUNET_CONSENSUS_AckMessage
112 /** 113 /**
113 * Do we want to keep and propagate the element? 114 * Do we want to keep and propagate the element?
114 */ 115 */
115 uint8_t keep; 116 uint8_t keep; /* FIXME: alignment!? */
116 117
117 /* FIXME: add message hash? */ 118 /* FIXME: add message hash? */
118}; 119};
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c
index 450d7b02c..19bf81c86 100644
--- a/src/consensus/consensus_api.c
+++ b/src/consensus/consensus_api.c
@@ -366,14 +366,11 @@ transmit_join (void *cls, size_t size, void *buf)
366 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); 366 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN);
367 msg->header.size = htons (msize); 367 msg->header.size = htons (msize);
368 msg->session_id = consensus->session_id; 368 msg->session_id = consensus->session_id;
369 msg->num_peers = htons (consensus->num_peers); 369 msg->num_peers = htonl (consensus->num_peers);
370 if (0 != msg->num_peers) 370 memcpy(&msg[1],
371 memcpy(&msg[1], 371 consensus->peers,
372 consensus->peers, 372 consensus->num_peers * sizeof (struct GNUNET_PeerIdentity));
373 consensus->num_peers * sizeof (struct GNUNET_PeerIdentity));
374
375 send_next (consensus); 373 send_next (consensus);
376
377 GNUNET_CLIENT_receive (consensus->client, &message_handler, consensus, 374 GNUNET_CLIENT_receive (consensus->client, &message_handler, consensus,
378 GNUNET_TIME_UNIT_FOREVER_REL); 375 GNUNET_TIME_UNIT_FOREVER_REL);
379 376
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c
index 2f59b86bc..494271e45 100644
--- a/src/consensus/gnunet-service-consensus.c
+++ b/src/consensus/gnunet-service-consensus.c
@@ -1405,15 +1405,15 @@ initialize_session_info (struct ConsensusSession *session)
1405static void 1405static void
1406initialize_session_peer_list (struct ConsensusSession *session) 1406initialize_session_peer_list (struct ConsensusSession *session)
1407{ 1407{
1408 int local_peer_in_list; 1408 unsigned int local_peer_in_list;
1409 int listed_peers; 1409 uint32_t listed_peers;
1410 const struct GNUNET_PeerIdentity *msg_peers; 1410 const struct GNUNET_PeerIdentity *msg_peers;
1411 unsigned int i; 1411 unsigned int i;
1412 1412
1413 GNUNET_assert (NULL != session->join_msg); 1413 GNUNET_assert (NULL != session->join_msg);
1414 1414
1415 /* peers in the join message, may or may not include the local peer */ 1415 /* peers in the join message, may or may not include the local peer */
1416 listed_peers = ntohs (session->join_msg->num_peers); 1416 listed_peers = ntohl (session->join_msg->num_peers);
1417 1417
1418 session->num_peers = listed_peers; 1418 session->num_peers = listed_peers;
1419 1419