diff options
-rw-r--r-- | src/messenger/gnunet-service-messenger.c | 2 | ||||
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 46 | ||||
-rw-r--r-- | src/revocation/revocation.h | 7 | ||||
-rw-r--r-- | src/revocation/revocation_api.c | 10 | ||||
-rw-r--r-- | src/revocation/test_revocation.c | 6 |
5 files changed, 52 insertions, 19 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c index e948ffee2..a2b6ad81e 100644 --- a/src/messenger/gnunet-service-messenger.c +++ b/src/messenger/gnunet-service-messenger.c | |||
@@ -225,7 +225,7 @@ check_send_message (void *cls, | |||
225 | return GNUNET_NO; | 225 | return GNUNET_NO; |
226 | 226 | ||
227 | const uint16_t msg_length = length - key_length; | 227 | const uint16_t msg_length = length - key_length; |
228 | const char*msg_buffer = buffer + key_length; | 228 | const char *msg_buffer = buffer + key_length; |
229 | 229 | ||
230 | struct GNUNET_MESSENGER_Message message; | 230 | struct GNUNET_MESSENGER_Message message; |
231 | 231 | ||
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index fe74201f3..e10771557 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -221,6 +221,23 @@ client_disconnect_cb (void *cls, | |||
221 | GNUNET_assert (client == app_cls); | 221 | GNUNET_assert (client == app_cls); |
222 | } | 222 | } |
223 | 223 | ||
224 | static int | ||
225 | check_query_message (void *cls, | ||
226 | const struct QueryMessage *qm) | ||
227 | { | ||
228 | uint16_t size; | ||
229 | |||
230 | size = ntohs (qm->header.size); | ||
231 | if (size <= sizeof(struct RevokeMessage) || | ||
232 | (size > UINT16_MAX)) | ||
233 | { | ||
234 | GNUNET_break (0); | ||
235 | return GNUNET_SYSERR; | ||
236 | } | ||
237 | return GNUNET_OK; | ||
238 | |||
239 | } | ||
240 | |||
224 | 241 | ||
225 | /** | 242 | /** |
226 | * Handle QUERY message from client. | 243 | * Handle QUERY message from client. |
@@ -233,13 +250,27 @@ handle_query_message (void *cls, | |||
233 | const struct QueryMessage *qm) | 250 | const struct QueryMessage *qm) |
234 | { | 251 | { |
235 | struct GNUNET_SERVICE_Client *client = cls; | 252 | struct GNUNET_SERVICE_Client *client = cls; |
253 | struct GNUNET_IDENTITY_PublicKey zone; | ||
236 | struct GNUNET_MQ_Envelope *env; | 254 | struct GNUNET_MQ_Envelope *env; |
237 | struct QueryResponseMessage *qrm; | 255 | struct QueryResponseMessage *qrm; |
238 | struct GNUNET_HashCode hc; | 256 | struct GNUNET_HashCode hc; |
239 | int res; | 257 | int res; |
240 | 258 | size_t key_len; | |
241 | GNUNET_CRYPTO_hash (&qm->key, | 259 | size_t read; |
242 | sizeof(struct GNUNET_IDENTITY_PublicKey), | 260 | |
261 | key_len = ntohl (qm->key_len); | ||
262 | if ((GNUNET_SYSERR == | ||
263 | GNUNET_IDENTITY_read_public_key_from_buffer (&qm[1], key_len, | ||
264 | &zone, &read)) || | ||
265 | (read != key_len)) | ||
266 | { | ||
267 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
268 | "Unable to parse query public key\n"); | ||
269 | GNUNET_SERVICE_client_drop (client); | ||
270 | return; | ||
271 | } | ||
272 | GNUNET_CRYPTO_hash (&qm[1], | ||
273 | key_len, | ||
243 | &hc); | 274 | &hc); |
244 | res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, | 275 | res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
245 | &hc); | 276 | &hc); |
@@ -316,6 +347,7 @@ publicize_rm (const struct RevokeMessage *rm) | |||
316 | const struct GNUNET_IDENTITY_PublicKey *pk | 347 | const struct GNUNET_IDENTITY_PublicKey *pk |
317 | = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 348 | = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
318 | 349 | ||
350 | /** FIXME yeah this works, but should we have a key length somewhere? */ | ||
319 | pklen = GNUNET_IDENTITY_public_key_get_length (pk); | 351 | pklen = GNUNET_IDENTITY_public_key_get_length (pk); |
320 | if (0 > pklen) | 352 | if (0 > pklen) |
321 | { | 353 | { |
@@ -1000,10 +1032,10 @@ GNUNET_SERVICE_MAIN | |||
1000 | &client_connect_cb, | 1032 | &client_connect_cb, |
1001 | &client_disconnect_cb, | 1033 | &client_disconnect_cb, |
1002 | NULL, | 1034 | NULL, |
1003 | GNUNET_MQ_hd_fixed_size (query_message, | 1035 | GNUNET_MQ_hd_var_size (query_message, |
1004 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, | 1036 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, |
1005 | struct QueryMessage, | 1037 | struct QueryMessage, |
1006 | NULL), | 1038 | NULL), |
1007 | GNUNET_MQ_hd_var_size (revoke_message, | 1039 | GNUNET_MQ_hd_var_size (revoke_message, |
1008 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 1040 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
1009 | struct RevokeMessage, | 1041 | struct RevokeMessage, |
diff --git a/src/revocation/revocation.h b/src/revocation/revocation.h index 490abf180..90b8c7da0 100644 --- a/src/revocation/revocation.h +++ b/src/revocation/revocation.h | |||
@@ -42,14 +42,13 @@ struct QueryMessage | |||
42 | struct GNUNET_MessageHeader header; | 42 | struct GNUNET_MessageHeader header; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * For alignment. | 45 | * Key length. |
46 | */ | 46 | */ |
47 | uint32_t reserved GNUNET_PACKED; | 47 | uint32_t key_len GNUNET_PACKED; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Key to check. | 50 | * Followed by the public key to check. |
51 | */ | 51 | */ |
52 | struct GNUNET_IDENTITY_PublicKey key; | ||
53 | }; | 52 | }; |
54 | 53 | ||
55 | 54 | ||
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 34b4eddd7..a0813ddcd 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -175,6 +175,7 @@ GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
175 | }; | 175 | }; |
176 | struct QueryMessage *qm; | 176 | struct QueryMessage *qm; |
177 | struct GNUNET_MQ_Envelope *env; | 177 | struct GNUNET_MQ_Envelope *env; |
178 | size_t key_len; | ||
178 | 179 | ||
179 | q->mq = GNUNET_CLIENT_connect (cfg, | 180 | q->mq = GNUNET_CLIENT_connect (cfg, |
180 | "revocation", | 181 | "revocation", |
@@ -188,10 +189,11 @@ GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
188 | } | 189 | } |
189 | q->func = func; | 190 | q->func = func; |
190 | q->func_cls = func_cls; | 191 | q->func_cls = func_cls; |
191 | env = GNUNET_MQ_msg (qm, | 192 | key_len = GNUNET_IDENTITY_public_key_get_length (key); |
192 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY); | 193 | env = GNUNET_MQ_msg_extra (qm, key_len, |
193 | qm->reserved = htonl (0); | 194 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY); |
194 | qm->key = *key; | 195 | GNUNET_IDENTITY_write_public_key_to_buffer (key, &qm[1], key_len); |
196 | qm->key_len = htonl (key_len); | ||
195 | GNUNET_MQ_send (q->mq, | 197 | GNUNET_MQ_send (q->mq, |
196 | env); | 198 | env); |
197 | return q; | 199 | return q; |
diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c index c6457016f..e6dd1a0db 100644 --- a/src/revocation/test_revocation.c +++ b/src/revocation/test_revocation.c | |||
@@ -195,16 +195,16 @@ ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
195 | static void | 195 | static void |
196 | identity_create_cb (void *cls, | 196 | identity_create_cb (void *cls, |
197 | const struct GNUNET_IDENTITY_PrivateKey *pk, | 197 | const struct GNUNET_IDENTITY_PrivateKey *pk, |
198 | const char *emsg) | 198 | enum GNUNET_ErrorCode ec) |
199 | { | 199 | { |
200 | static int completed = 0; | 200 | static int completed = 0; |
201 | 201 | ||
202 | if ((NULL == emsg) && (cls == &testpeers[0])) | 202 | if ((GNUNET_EC_NONE == ec) && (cls == &testpeers[0])) |
203 | { | 203 | { |
204 | testpeers[0].create_id_op = NULL; | 204 | testpeers[0].create_id_op = NULL; |
205 | completed++; | 205 | completed++; |
206 | } | 206 | } |
207 | if ((NULL == emsg) && (cls == &testpeers[1])) | 207 | if ((GNUNET_EC_NONE == ec) && (cls == &testpeers[1])) |
208 | { | 208 | { |
209 | testpeers[1].create_id_op = NULL; | 209 | testpeers[1].create_id_op = NULL; |
210 | completed++; | 210 | completed++; |