aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-service-revocation.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-10-29 21:36:05 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-10-29 21:36:05 +0900
commit87948bf6eece00bfa6f3fe5b3787b8626c6de37b (patch)
tree558b15f56c10066728eb2d84e20a3d675fde4858 /src/revocation/gnunet-service-revocation.c
parent597404615c3d7793b88ababe3410cffadc3f7715 (diff)
downloadgnunet-87948bf6eece00bfa6f3fe5b3787b8626c6de37b.tar.gz
gnunet-87948bf6eece00bfa6f3fe5b3787b8626c6de37b.zip
-fix revocation API
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r--src/revocation/gnunet-service-revocation.c46
1 files changed, 39 insertions, 7 deletions
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
224static int
225check_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,