Skip to content

Commit f7d8b27

Browse files
committed
Fix bug ext\standard\tests\file\realpath_cache_win32.phpt fails
What happens here is trivial long overflow. Despite the bug attracted attention on windows, the same story is on linux. Just wait for a big anough bucket->key . The linux test had %i to check the key value which should be %d all the way.
1 parent 7fb16d5 commit f7d8b27

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

ext/standard/filestat.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,12 @@ PHP_FUNCTION(realpath_cache_get)
11601160
MAKE_STD_ZVAL(entry);
11611161
array_init(entry);
11621162

1163-
add_assoc_long(entry, "key", bucket->key);
1163+
/* bucket->key is unsigned long */
1164+
if (LONG_MAX >= bucket->key) {
1165+
add_assoc_long(entry, "key", bucket->key);
1166+
} else {
1167+
add_assoc_double(entry, "key", (double)bucket->key);
1168+
}
11641169
add_assoc_bool(entry, "is_dir", bucket->is_dir);
11651170
add_assoc_stringl(entry, "realpath", bucket->realpath, bucket->realpath_len, 1);
11661171
add_assoc_long(entry, "expires", bucket->expires);

ext/standard/tests/file/realpath_cache.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ echo "Done\n";
1919
int(%d)
2020
array(4) {
2121
["key"]=>
22-
int(%i)
22+
%s(%d)
2323
["is_dir"]=>
2424
bool(true)
2525
["realpath"]=>

ext/standard/tests/file/realpath_cache_win32.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ echo "Done\n";
1919
int(%d)
2020
array(8) {
2121
["key"]=>
22-
int(%d)
22+
%s(%d)
2323
["is_dir"]=>
2424
bool(true)
2525
["realpath"]=>

0 commit comments

Comments
 (0)