Commit eb33623c786 for php.net
commit eb33623c7868c1606486da60069ca580793fac9c
Author: jvoisin <julien.voisin@dustri.org>
Date: Tue Sep 22 01:48:30 2026 +0800
Backport: fix integer overflow in mhash_keygen_s2k (#23770)
Backport PR #23770 from master to PHP-8.4.
Original commit: 5e021664d84465d9b020bacd257fc407697b408f
Closes #23770
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 2f8cef87da3..93401852ad3 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -1328,7 +1328,7 @@ PHP_FUNCTION(mhash_keygen_s2k)
context = php_hash_alloc_context(ops);
ops->hash_init(context, NULL);
- key = ecalloc(1, times * block_size);
+ key = ecalloc(times, block_size);
digest = emalloc(ops->digest_size + 1);
for (i = 0; i < times; i++) {