diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-05-01 15:59:14 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-05-01 16:08:17 +0300 |
commit | a3527f080a807060ddc4ae4bb4e395194c1bfd16 (patch) | |
tree | ca98f4a161f8276c7cc2b1428fea7d3368e1eb91 /src/microhttpd/digestauth.c | |
parent | 628a28d6072acdfccf6237eca6743ac0caf7e921 (diff) | |
download | libmicrohttpd-a3527f080a807060ddc4ae4bb4e395194c1bfd16.tar.gz libmicrohttpd-a3527f080a807060ddc4ae4bb4e395194c1bfd16.zip |
check_nonce_nc(): improved readability, fixed comments
Diffstat (limited to 'src/microhttpd/digestauth.c')
-rw-r--r-- | src/microhttpd/digestauth.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c index 81e50785..d4c0f247 100644 --- a/src/microhttpd/digestauth.c +++ b/src/microhttpd/digestauth.c | |||
@@ -614,6 +614,8 @@ check_nonce_nc (struct MHD_Connection *connection, | |||
614 | if ( (0 != memcmp (nn->nonce, nonce, noncelen)) || | 614 | if ( (0 != memcmp (nn->nonce, nonce, noncelen)) || |
615 | (0 != nn->nonce[noncelen]) ) | 615 | (0 != nn->nonce[noncelen]) ) |
616 | ret = false; /* Nonce does not match, fail */ | 616 | ret = false; /* Nonce does not match, fail */ |
617 | else if (nc == nn->nc) | ||
618 | ret = false; /* 'nc' was already used */ | ||
617 | /* Note that we use 64 here, as we do not store the | 619 | /* Note that we use 64 here, as we do not store the |
618 | bit for 'nn->nc' itself in 'nn->nmask' */ | 620 | bit for 'nn->nc' itself in 'nn->nmask' */ |
619 | else if ( (nc < nn->nc) && | 621 | else if ( (nc < nn->nc) && |
@@ -625,11 +627,11 @@ check_nonce_nc (struct MHD_Connection *connection, | |||
625 | nn->nmask |= (1LLU << (nn->nc - nc - 1)); | 627 | nn->nmask |= (1LLU << (nn->nc - nc - 1)); |
626 | ret = true; | 628 | ret = true; |
627 | } | 629 | } |
628 | else if (nc <= nn->nc) | 630 | else if (nc < nn->nc) |
629 | ret = false; /* Nonce does not match, fail */ | 631 | ret = false; /* 'nc' does not match, fail */ |
630 | else | 632 | else |
631 | { | 633 | { |
632 | /* Nonce is larger, shift bitmask and bump limit */ | 634 | /* 'nc' is larger, shift bitmask and bump limit */ |
633 | if (64 > nc - nn->nc) | 635 | if (64 > nc - nn->nc) |
634 | nn->nmask <<= (nc - nn->nc); /* small jump, less than mask width */ | 636 | nn->nmask <<= (nc - nn->nc); /* small jump, less than mask width */ |
635 | else | 637 | else |