diff options
author | Milan Broz <gmazyland@gmail.com> | 2024-04-18 08:39:52 +0200 |
---|---|---|
committer | Milan Broz <gmazyland@gmail.com> | 2024-04-18 08:39:52 +0200 |
commit | 33e26be58be852df80f945f328f5ee408a313563 (patch) | |
tree | af00fb7df9eea2f3c76f34852d38c4cb6bbd12d2 | |
parent | 842d9e6e6e78bc36a47b828018821d57eb9ea9f4 (diff) | |
download | cryptsetup-33e26be58be852df80f945f328f5ee408a313563.tar.gz |
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.
-rw-r--r-- | lib/internal.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/internal.h b/lib/internal.h index 3a0d6e64..38b99d91 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -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; |