Avoid divide by zero in uint64_mult_overflow.

This function is used with block size, where 0 does
not make sense, so failing the check is the simple way
to avoid sividion by zero.

In reality, this should never happen, but it was seen
in (unreproducible) fuzzing input.
This commit is contained in:
Milan Broz
2024-04-18 08:39:52 +02:00
parent 842d9e6e6e
commit 33e26be58b

View File

@@ -266,6 +266,8 @@ static inline void *crypt_zalloc(size_t size) { return calloc(1, size); }
static inline bool uint64_mult_overflow(uint64_t *u, uint64_t b, size_t size)
{
*u = (uint64_t)b * size;
if (size == 0)
return true;
if ((uint64_t)(*u / size) != b)
return true;
return false;