check_nonce_nc(): fixed missing set of the bit for the old 'nc' value

When 'nc' values are increased sequentially, the bit for the old 'nc'
value was not set.
This commit is contained in:
Evgeny Grin (Karlson2k)
2022-05-01 16:44:53 +03:00
parent 8457dfc7b6
commit f473462465
+10 -2
View File
@@ -634,8 +634,16 @@ check_nonce_nc (struct MHD_Connection *connection,
else
{
/* 'nc' is larger, shift bitmask and bump limit */
if (64 > nc - nn->nc)
nn->nmask <<= (nc - nn->nc); /* small jump, less than mask width */
const uint64_t jump_size = nc - nn->nc;
if (64 > jump_size)
{
/* small jump, less than mask width */
nn->nmask <<= jump_size;
/* Set bit for the old 'nc' value */
nn->nmask |= (UINT64_C (1) << (jump_size - 1));
}
else if (64 == jump_size)
nn->nmask = (UINT64_C (1) << 63);
else
nn->nmask = 0; /* big jump, unset all bits in the mask */
nn->nc = nc;