gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: -fix revocation API


From: gnunet
Subject: [gnunet] branch master updated: -fix revocation API
Date: Sat, 29 Oct 2022 14:36:12 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 87948bf6e -fix revocation API
87948bf6e is described below

commit 87948bf6eece00bfa6f3fe5b3787b8626c6de37b
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Oct 29 21:36:05 2022 +0900

    -fix revocation API
---
 src/messenger/gnunet-service-messenger.c   |  2 +-
 src/revocation/gnunet-service-revocation.c | 46 +++++++++++++++++++++++++-----
 src/revocation/revocation.h                |  7 ++---
 src/revocation/revocation_api.c            | 10 ++++---
 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,
       return GNUNET_NO;
 
   const uint16_t msg_length = length - key_length;
-  const char*msg_buffer = buffer + key_length;
+  const char *msg_buffer = buffer + key_length;
 
   struct GNUNET_MESSENGER_Message message;
 
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,
   GNUNET_assert (client == app_cls);
 }
 
+static int
+check_query_message (void *cls,
+                     const struct QueryMessage *qm)
+{
+  uint16_t size;
+
+  size = ntohs (qm->header.size);
+  if (size <= sizeof(struct RevokeMessage) ||
+      (size > UINT16_MAX))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
+  return GNUNET_OK;
+
+}
+
 
 /**
  * Handle QUERY message from client.
@@ -233,13 +250,27 @@ handle_query_message (void *cls,
                       const struct QueryMessage *qm)
 {
   struct GNUNET_SERVICE_Client *client = cls;
+  struct GNUNET_IDENTITY_PublicKey zone;
   struct GNUNET_MQ_Envelope *env;
   struct QueryResponseMessage *qrm;
   struct GNUNET_HashCode hc;
   int res;
-
-  GNUNET_CRYPTO_hash (&qm->key,
-                      sizeof(struct GNUNET_IDENTITY_PublicKey),
+  size_t key_len;
+  size_t read;
+
+  key_len = ntohl (qm->key_len);
+  if ((GNUNET_SYSERR ==
+       GNUNET_IDENTITY_read_public_key_from_buffer (&qm[1], key_len,
+                                                    &zone, &read)) ||
+      (read != key_len))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unable to parse query public key\n");
+    GNUNET_SERVICE_client_drop (client);
+    return;
+  }
+  GNUNET_CRYPTO_hash (&qm[1],
+                      key_len,
                       &hc);
   res = GNUNET_CONTAINER_multihashmap_contains (revocation_map,
                                                 &hc);
@@ -316,6 +347,7 @@ publicize_rm (const struct RevokeMessage *rm)
   const struct GNUNET_IDENTITY_PublicKey *pk
     = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
 
+  /** FIXME yeah this works, but should we have a key length somewhere? */
   pklen = GNUNET_IDENTITY_public_key_get_length (pk);
   if (0 > pklen)
   {
@@ -1000,10 +1032,10 @@ GNUNET_SERVICE_MAIN
   &client_connect_cb,
   &client_disconnect_cb,
   NULL,
-  GNUNET_MQ_hd_fixed_size (query_message,
-                           GNUNET_MESSAGE_TYPE_REVOCATION_QUERY,
-                           struct QueryMessage,
-                           NULL),
+  GNUNET_MQ_hd_var_size (query_message,
+                         GNUNET_MESSAGE_TYPE_REVOCATION_QUERY,
+                         struct QueryMessage,
+                         NULL),
   GNUNET_MQ_hd_var_size (revoke_message,
                          GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE,
                          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
   struct GNUNET_MessageHeader header;
 
   /**
-   * For alignment.
+   * Key length.
    */
-  uint32_t reserved GNUNET_PACKED;
+  uint32_t key_len GNUNET_PACKED;
 
   /**
-   * Key to check.
+   * Followed by the public key to check.
    */
-  struct GNUNET_IDENTITY_PublicKey key;
 };
 
 
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,
   };
   struct QueryMessage *qm;
   struct GNUNET_MQ_Envelope *env;
+  size_t key_len;
 
   q->mq = GNUNET_CLIENT_connect (cfg,
                                  "revocation",
@@ -188,10 +189,11 @@ GNUNET_REVOCATION_query (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
   }
   q->func = func;
   q->func_cls = func_cls;
-  env = GNUNET_MQ_msg (qm,
-                       GNUNET_MESSAGE_TYPE_REVOCATION_QUERY);
-  qm->reserved = htonl (0);
-  qm->key = *key;
+  key_len = GNUNET_IDENTITY_public_key_get_length (key);
+  env = GNUNET_MQ_msg_extra (qm, key_len,
+                             GNUNET_MESSAGE_TYPE_REVOCATION_QUERY);
+  GNUNET_IDENTITY_write_public_key_to_buffer (key, &qm[1], key_len);
+  qm->key_len = htonl (key_len);
   GNUNET_MQ_send (q->mq,
                   env);
   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)
 static void
 identity_create_cb (void *cls,
                     const struct GNUNET_IDENTITY_PrivateKey *pk,
-                    const char *emsg)
+                    enum GNUNET_ErrorCode ec)
 {
   static int completed = 0;
 
-  if ((NULL == emsg) && (cls == &testpeers[0]))
+  if ((GNUNET_EC_NONE == ec) && (cls == &testpeers[0]))
   {
     testpeers[0].create_id_op = NULL;
     completed++;
   }
-  if ((NULL == emsg) && (cls == &testpeers[1]))
+  if ((GNUNET_EC_NONE == ec) && (cls == &testpeers[1]))
   {
     testpeers[1].create_id_op = NULL;
     completed++;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]