gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 08/09: check_nonce_nc(): additionally improved readabili


From: gnunet
Subject: [libmicrohttpd] 08/09: check_nonce_nc(): additionally improved readability, fixed comments
Date: Sun, 01 May 2022 16:08:54 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit c0bb909f0a54c7cb41e0e9e0fb936ed8fa79fdc5
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun May 1 16:57:58 2022 +0300

    check_nonce_nc(): additionally improved readability, fixed comments
---
 src/microhttpd/digestauth.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 39496727..2bfbf95e 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -619,18 +619,21 @@ check_nonce_nc (struct MHD_Connection *connection,
     ret = false;     /* Nonce does not match, fail */
   else if (nc == nn->nc)
     ret = false;     /* 'nc' was already used */
-  /* Note that we use 64 here, as we do not store the
-     bit for 'nn->nc' itself in 'nn->nmask' */
-  else if ( (nc < nn->nc) &&
-            (nc + 64 >= nn->nc) &&
-            (0 == ((1LLU << (nn->nc - nc - 1)) & nn->nmask)) )
+  else if (nc < nn->nc)
   {
-    /* Out-of-order nonce, but within 64-bit bitmask, set bit */
-    nn->nmask |= (1LLU << (nn->nc - nc - 1));
-    ret = true;
+    /* Note that we use 64 here, as we do not store the
+       bit for 'nn->nc' itself in 'nn->nmask' */
+    if ( (nc + 64 >= nn->nc) &&
+         (0 == ((1LLU << (nn->nc - nc - 1)) & nn->nmask)) )
+    {
+      /* Out-of-order nonce, but within 64-bit bitmask, set bit */
+      nn->nmask |= (1LLU << (nn->nc - nc - 1));
+      ret = true;
+    }
+    else
+      /* 'nc' was already used or too old (more then 64 values ago) */
+      ret = false;
   }
-  else if (nc < nn->nc)
-    ret = false; /* 'nc' does not match, fail */
   else
   {
     /* 'nc' is larger, shift bitmask and bump limit */

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