aboutsummaryrefslogtreecommitdiffstats
path: root/libar2_hash_buf_size.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libar2_hash_buf_size.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libar2_hash_buf_size.c b/libar2_hash_buf_size.c
index b165d4b..109969f 100644
--- a/libar2_hash_buf_size.c
+++ b/libar2_hash_buf_size.c
@@ -5,5 +5,11 @@
size_t
libar2_hash_buf_size(struct libar2_argon2_parameters *params)
{
- return (params->hashlen > 64 && (params->hashlen & 127)) ? (params->hashlen | 127) + 1 : params->hashlen;
+ if (params->hashlen <= 64)
+ return params->hashlen;
+ if (params->hashlen > SIZE_MAX / 128 * 64 - 31) {
+ errno = EOVERFLOW;
+ return 0;
+ }
+ return (params->hashlen + 31) / 64 * 128;
}