Skip to content

Commit 7fa674b

Browse files
committed
ext/hash: Fix GH-16711: Segfault in mhash()
1 parent 36d9ae7 commit 7fa674b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

ext/hash/hash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,11 @@ PHP_FUNCTION(mhash)
12131213
struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm];
12141214
if (algorithm_lookup.hash_name) {
12151215
algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0);
1216+
} else {
1217+
RETURN_FALSE;
12161218
}
1219+
} else {
1220+
RETURN_FALSE;
12171221
}
12181222

12191223
if (key) {

ext/hash/tests/gh16711_1.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
GH-16711: Segmentation fault in mhash()
33
--SKIPIF--
44
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
5-
--XFAIL--
6-
SEGFAULT
75
--FILE--
86
<?php
97

@@ -97,4 +95,4 @@ array(40) {
9795
}
9896

9997
Deprecated: Function mhash() is deprecated in %s on line %d
100-
SEGFAULT
98+
bool(false)

ext/hash/tests/gh16711_2.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
GH-16711: Segmentation fault in mhash()
33
--SKIPIF--
44
<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
5-
--XFAIL--
6-
SEGFAULT
75
--FILE--
86
<?php
97

@@ -97,4 +95,4 @@ array(40) {
9795
}
9896

9997
Deprecated: Function mhash() is deprecated in %s on line %d
100-
SEGFAULT
98+
bool(false)

0 commit comments

Comments
 (0)