[php-src] PHP-8.4: Backport: fix integer overflow in mhash_keygen_s2k (#23770)
| From: | jvoisin via Weilin Du | Date: | Mon, 21 Sep 2026 17:55:25 +0000 |
| Subject: | [php-src] PHP-8.4: Backport: fix integer overflow in mhash_keygen_s2k (#23770) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141343@lists.php.net to get a copy of this message | ||
Author: jvoisin (jvoisin)
Committer: Weilin Du (LamentXU123)
Date: 2026-09-22T01:53:25+08:00
Commit: https://github.com/php/php-src/commit/eb33623c7868c1606486da60069ca580793fac9c
Raw diff: https://github.com/php/php-src/commit/eb33623c7868c1606486da60069ca580793fac9c.diff
Backport: fix integer overflow in mhash_keygen_s2k (#23770)
Backport PR #23770 from master to PHP-8.4.
Original commit: 5e021664d84465d9b020bacd257fc407697b408f
Closes #23770
Changed paths:
M ext/hash/hash.c
Diff:
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 2f8cef87da37..93401852ad3d 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++) {