gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (9f226932 -> c5593989)


From: gnunet
Subject: [libmicrohttpd] branch master updated (9f226932 -> c5593989)
Date: Fri, 06 May 2022 10:59:25 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 9f226932 Fixed additional wrong (inverted) asserts
     new 05a79fdb digestauth: fixed logic of free nonce-nc slot detection
     new c5593989 digestauth: added two more asserts

The 2 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/microhttpd/digestauth.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 78fbd2d9..11512db0 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -569,6 +569,7 @@ get_nonce_nc_idx (size_t arr_size,
                   size_t noncelen)
 {
   mhd_assert (0 != arr_size);
+  mhd_assert (0 != noncelen);
   return fast_simple_hash ((const uint8_t *) nonce, noncelen) % arr_size;
 }
 
@@ -845,11 +846,8 @@ is_slot_available (const struct MHD_NonceNc *const nn,
   if (0 == nn->nonce[0])
     return true; /* The slot is empty */
 
-  if (0 != nn->nc)
-    return true; /* Client already used the nonce in this slot at least
-                    one time, re-use the slot */
-
-  if (0 == memcmp (nn->nonce, new_nonce, new_nonce_len + 1))
+  if ((0 == memcmp (nn->nonce, new_nonce, new_nonce_len)) &&
+      (0 == nn->nonce[new_nonce_len]))
   {
     /* The slot has the same nonce already, the same nonce was already 
generated
      * and used, this slot cannot be used with the same nonce as it would
@@ -857,6 +855,10 @@ is_slot_available (const struct MHD_NonceNc *const nn,
     return false;
   }
 
+  if (0 != nn->nc)
+    return true; /* Client already used the nonce in this slot at least
+                    one time, re-use the slot */
+
   timestamp_valid = get_nonce_timestamp (nn->nonce, 0, &timestamp);
   mhd_assert (timestamp_valid);
   if (! timestamp_valid)
@@ -981,7 +983,7 @@ calculate_add_nonce_with_retry (struct MHD_Connection 
*const connection,
       base4 = ((uint8_t) (base3 >> 8)) ^ ((uint8_t) base3);
       base1 = (uint64_t) (uintptr_t) connection;
       base2 = ((uint32_t) (base1 >> 32)) ^ ((uint32_t) base1);
-      base2 = _MHD_ROTL32 (base2, (((base1 >> 4) ^ base1) % 32));
+      base2 = _MHD_ROTL32 (base2, (((base4 >> 4) ^ base4) % 32));
       base3 = ((uint16_t) (base2 >> 16)) ^ ((uint16_t) base2);
       base4 = ((uint8_t) (base3 >> 8)) ^ ((uint8_t) base3);
       timestamp2 -= (base4 & 0x7f); /* Use up to 127 ms difference */
@@ -994,7 +996,8 @@ calculate_add_nonce_with_retry (struct MHD_Connection 
*const connection,
        * so client should re-try automatically. */
       return false;
     }
-    memcpy (nonce, nonce2, NONCE_STD_LEN (digest_size) + 1);
+    memcpy (nonce, nonce2, NONCE_STD_LEN (digest_size));
+    mhd_assert (0 == nonce[NONCE_STD_LEN (digest_size)]);
   }
   return true;
 }

-- 
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]