digestauth: limit nonce-count to uint32_t

This commit is contained in:
Evgeny Grin (Karlson2k)
2022-08-09 21:24:55 +03:00
parent 20001736f8
commit 228ddbd181
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -590,7 +590,7 @@ check_nonce_nc (struct MHD_Connection *connection,
mod = daemon->nonce_nc_size;
if (0 == mod)
return MHD_CHECK_NONCENC_STALE; /* no array! */
if (nc >= UINT64_MAX - 64)
if (nc >= UINT32_MAX - 64)
return MHD_CHECK_NONCENC_STALE; /* Overflow, unrealistically high value */
nn = &daemon->nnc[get_nonce_nc_idx (mod, nonce, noncelen)];
@@ -649,7 +649,7 @@ check_nonce_nc (struct MHD_Connection *connection,
else if (nc > nn->nc)
{
/* 'nc' is larger, shift bitmask and bump limit */
const uint64_t jump_size = nc - nn->nc;
const uint32_t jump_size = (uint32_t) nc - nn->nc;
if (64 > jump_size)
{
/* small jump, less than mask width */
@@ -661,7 +661,7 @@ check_nonce_nc (struct MHD_Connection *connection,
nn->nmask = (UINT64_C (1) << 63);
else
nn->nmask = 0; /* big jump, unset all bits in the mask */
nn->nc = nc;
nn->nc = (uint32_t) nc;
ret = MHD_CHECK_NONCENC_OK;
}
else if (nc < nn->nc)
+1 -1
View File
@@ -268,7 +268,7 @@ struct MHD_NonceNc
* 'nc' value.
* This 'nc' value was already used by the client.
*/
uint64_t nc;
uint32_t nc;
/**
* Bitmask over the previous 64 nonce counter values (down to to nc-64).