mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user