gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (03a99aa00 -> 52255b0df)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (03a99aa00 -> 52255b0df)
Date: Sun, 22 Jan 2017 23:55:03 +0100

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

grothoff pushed a change to branch master
in repository gnunet.

    from 03a99aa00 allow client's payload to include more than one message
     new 69a00f58f guard against 0
     new 22141e7eb simplify check_data logic
     new 4812be406 do not send malformed payload in test
     new 262926a53 log precise error if we receive malformed data
     new 52255b0df remove actually problematic client_allowed check

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cadet/gnunet-service-cadet-new.c         | 28 ++++++++++++++++++----------
 src/cadet/gnunet-service-cadet-new_channel.c | 14 ++------------
 src/cadet/test_cadet.c                       | 27 ++++++++++++++++++---------
 3 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/src/cadet/gnunet-service-cadet-new.c 
b/src/cadet/gnunet-service-cadet-new.c
index 78d4206f0..bb251c307 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -629,29 +629,37 @@ check_data (void *cls,
   const char *buf;
   struct GNUNET_MessageHeader pa;
 
+  /* FIXME: what is the format we shall allow for @a msg?
+     ONE payload item or multiple? Seems current cadet_api
+     at least in theory allows more than one. Next-gen
+     cadet_api will likely no more, so we could then
+     simplify this mess again. */
   /* Sanity check for message size */
   payload_size = ntohs (msg->header.size) - sizeof (*msg);
-  if ( (payload_size < sizeof (struct GNUNET_MessageHeader)) ||
-       (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_size) )
-  {
-    GNUNET_break (0);
-    return GNUNET_SYSERR;
-  }
   buf = (const char *) &msg[1];
-  do {
+  while (payload_size >= sizeof (struct GNUNET_MessageHeader))
+  {
     /* need to memcpy() for alignment */
     GNUNET_memcpy (&pa,
                    buf,
                    sizeof (pa));
     payload_claimed_size = ntohs (pa.size);
-    if (payload_size < payload_claimed_size)
+    if ( (payload_size < payload_claimed_size) ||
+         (payload_claimed_size < sizeof (struct GNUNET_MessageHeader)) ||
+         (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE < payload_claimed_size) )
     {
-      GNUNET_break_op (0);
+      GNUNET_break (0);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Local data of %u total size had sub-message %u at %u with %u 
bytes\n",
+           ntohs (msg->header.size),
+           ntohs (pa.type),
+           (unsigned int) (buf - (const char *) &msg[1]),
+           (unsigned int) payload_claimed_size);
       return GNUNET_SYSERR;
     }
     payload_size -= payload_claimed_size;
     buf += payload_claimed_size;
-  } while (payload_size >= sizeof (struct GNUNET_MessageHeader));
+  }
   if (0 != payload_size)
   {
     GNUNET_break_op (0);
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c 
b/src/cadet/gnunet-service-cadet-new_channel.c
index 42565d276..f45c5e5ce 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.c
+++ b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -287,11 +287,6 @@ struct CadetChannel
   int client_ready;
 
   /**
-   * Can the client send data to us?
-   */
-  int client_allowed;
-
-  /**
    * Is the tunnel bufferless (minimum latency)?
    */
   int nobuffer;
@@ -1165,8 +1160,6 @@ GCCH_check_allow_client (struct CadetChannel *ch)
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_CADET_LocalAck *msg;
 
-  if (GNUNET_YES == ch->client_allowed)
-    return; /* client already allowed! */
   if (CADET_CHANNEL_READY != ch->state)
   {
     /* destination did not yet ACK our CREATE! */
@@ -1191,8 +1184,6 @@ GCCH_check_allow_client (struct CadetChannel *ch)
          GCCH_2s (ch));
     return;
   }
-  ch->client_allowed = GNUNET_YES;
-
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Sending local ack to %s client\n",
@@ -1292,12 +1283,11 @@ GCCH_handle_local_data (struct CadetChannel *ch,
 {
   struct CadetReliableMessage *crm;
 
-  if (GNUNET_NO == ch->client_allowed)
+  if (ch->pending_messages > ch->max_pending_messages)
   {
-    GNUNET_break_op (0);
+    GNUNET_break (0);
     return GNUNET_SYSERR;
   }
-  ch->client_allowed = GNUNET_NO;
   ch->pending_messages++;
 
   /* Everything is correct, send the message. */
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index a411b41bc..16466ca0d 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -527,7 +527,7 @@ data_task (void *cls)
  * @param size Size of the buffer we have.
  * @param buf Buffer to copy data to.
  */
-size_t
+static size_t
 tmt_rdy (void *cls, size_t size, void *buf)
 {
   struct GNUNET_MessageHeader *msg = buf;
@@ -536,7 +536,9 @@ tmt_rdy (void *cls, size_t size, void *buf)
   long id = (long) cls;
   unsigned int counter;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "tmt_rdy on %ld, filling buffer\n",
+              id);
   if (0 == id)
     th = NULL;
   else if ((peers_requested - 1) == id)
@@ -545,7 +547,9 @@ tmt_rdy (void *cls, size_t size, void *buf)
     GNUNET_assert (0);
   counter = get_expected_target () == id ? ack_sent : data_sent;
   msg_size = size_payload + counter;
-  if (size < msg_size || NULL == buf)
+  GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
+  if ( (size < msg_size) ||
+       (NULL == buf) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "size %u, buf %p, data_sent %u, ack_received %u\n",
@@ -564,12 +568,15 @@ tmt_rdy (void *cls, size_t size, void *buf)
   *data = htonl (counter);
   if (GNUNET_NO == initialized)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "sending initializer\n");
     msg_size = size_payload + 1000;
-    if (SPEED_ACK == test)
+    msg->size = htons (msg_size);
+  if (SPEED_ACK == test)
       data_sent++;
   }
-  else if (SPEED == test || SPEED_ACK == test)
+  else if ( (SPEED == test) ||
+            (SPEED_ACK == test) )
   {
     if (get_expected_target() == id)
       ack_sent++;
@@ -580,9 +587,11 @@ tmt_rdy (void *cls, size_t size, void *buf)
                 " Sent message %u size %u\n",
                 counter,
                 (unsigned int) msg_size);
-    if (data_sent < TOTAL_PACKETS && SPEED == test)
+    if ( (data_sent < TOTAL_PACKETS) &&
+         (SPEED == test) )
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n",
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  " Scheduling message %d\n",
                   counter + 1);
       data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
     }
@@ -595,7 +604,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
 /**
  * Function is called whenever a message is received.
  *
- * @param cls closure (set from GNUNET_CADET_connect, peer number)
+ * @param cls closure (set from GNUNET_CADET_connect(), peer number)
  * @param channel connection to the other end
  * @param channel_ctx place to store local state associated with the channel
  * @param message the actual message

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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