Skip to content

Commit baa07f3

Browse files
committed
Fix GH-11180: hash_file() appears to be restricted to 3 arguments
Closes GH-11198.
1 parent 7c0dfc5 commit baa07f3

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
. Fixed bug GH-11189 (Exceeding memory limit in zend_hash_do_resize leaves
99
the array in an invalid state). (Bob)
1010

11+
- Hash:
12+
. Fixed bug GH-11180 (hash_file() appears to be restricted to 3 arguments).
13+
(nielsdos)
14+
1115
- LibXML:
1216
. Fixed bug GH-11160 (Few tests failed building with new libxml 2.11.0).
1317
(nielsdos)

ext/hash/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ PHP_FUNCTION(hash_file)
449449
bool raw_output = 0;
450450
HashTable *args = NULL;
451451

452-
ZEND_PARSE_PARAMETERS_START(2, 3)
452+
ZEND_PARSE_PARAMETERS_START(2, 4)
453453
Z_PARAM_STR(algo)
454454
Z_PARAM_STRING(data, data_len)
455455
Z_PARAM_OPTIONAL

ext/hash/tests/hash_file_basic1.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ echo "sha512: " . hash_file('sha512', $file). "\n";
4242
echo "snefru: " . hash_file('snefru', $file). "\n";
4343
echo "tiger192,3: " . hash_file('tiger192,3', $file). "\n";
4444
echo "whirlpool: " . hash_file('whirlpool', $file). "\n";
45+
echo "murmur3a: " . hash_file('murmur3a', $file). "\n";
46+
echo "murmur3a: " . hash_file('murmur3a', $file, false, ['seed' => 1234]). "\n";
47+
echo "murmur3c: " . hash_file('murmur3c', $file). "\n";
48+
echo "murmur3c: " . hash_file('murmur3c', $file, false, ['seed' => 1234]). "\n";
49+
echo "murmur3f: " . hash_file('murmur3f', $file). "\n";
50+
echo "murmur3f: " . hash_file('murmur3f', $file, false, ['seed' => 1234]). "\n";
4551

4652
echo "adler32(raw): " . bin2hex(hash_file('adler32', $file, TRUE)) . "\n";
4753
echo "md5(raw): " . bin2hex(hash_file('md5', $file, TRUE)). "\n";
@@ -70,6 +76,12 @@ sha512: 1f42adaf938fbf136e381b164bae5f984c7f9fe60c82728bd889c14f187c7d63e81a0305
7076
snefru: d414b2345d3e7fa1a31c044cf334bfc1fec24d89e464411998d579d24663895f
7177
tiger192,3: 7acf4ebea075fac6fc8ea0e2b4af3cfa71b9460e4c53403a
7278
whirlpool: 4248b149e000477269a4a5f1a84d97cfc3d0199b7aaf505913e6f010a6f83276029d11a9ad545374bc710eb59c7d958985023ab886ffa9ec9a23852844c764ec
79+
murmur3a: bc6554c8
80+
murmur3a: 432e4379
81+
murmur3c: 8779de509ffc06fb27bcf5fc861504d6
82+
murmur3c: b43afac65c38a617323020432c170005
83+
murmur3f: 2b84cd546b2f18a9ab6f893194224afd
84+
murmur3f: 6cc7716646664d6a83d68cb6563ac38e
7385
adler32(raw): ff87222e
7486
md5(raw): 704bf818448f5bbb94061332d2c889aa
7587
sha256(raw): a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245

0 commit comments

Comments
 (0)