Skip to content

Commit

Permalink
ext/hash: Fix phpGH-16711: Segfault in mhash()
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Nov 10, 2024
1 parent fc8f30d commit 1b379f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ PHP NEWS
- FPM:
. Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka)

- Hash:
. Fixed GH-16711: Segfault in mhash(). (Girgias)

- OpenSSL:
. Prevent unexpected array entry conversion when reading key. (nielsdos)
. Fix various memory leaks related to openssl exports. (nielsdos)
Expand Down
4 changes: 4 additions & 0 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,11 @@ PHP_FUNCTION(mhash)
struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm];
if (algorithm_lookup.hash_name) {
algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0);
} else {
RETURN_FALSE;
}
} else {
RETURN_FALSE;
}

if (key) {
Expand Down
4 changes: 1 addition & 3 deletions ext/hash/tests/gh16711_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
GH-16711: Segmentation fault in mhash()
--SKIPIF--
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
--XFAIL--
SEGFAULT
--FILE--
<?php

Expand Down Expand Up @@ -97,4 +95,4 @@ array(40) {
}

Deprecated: Function mhash() is deprecated in %s on line %d
SEGFAULT
bool(false)
4 changes: 1 addition & 3 deletions ext/hash/tests/gh16711_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
GH-16711: Segmentation fault in mhash()
--SKIPIF--
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
--XFAIL--
SEGFAULT
--FILE--
<?php

Expand Down Expand Up @@ -97,4 +95,4 @@ array(40) {
}

Deprecated: Function mhash() is deprecated in %s on line %d
SEGFAULT
bool(false)

0 comments on commit 1b379f5

Please sign in to comment.