From: Anatoliy Belsky Date: Thu, 10 May 2012 13:27:44 +0000 (+0200) Subject: Fix bug ext\standard\tests\file\realpath_cache_win32.phpt fails X-Git-Tag: php-5.3.14RC1~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7d8b274c7affabd3158075ff1feec45e2cdf56f;p=php 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. --- diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 94a7b89b87..349526ecfd 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -1160,7 +1160,12 @@ PHP_FUNCTION(realpath_cache_get) MAKE_STD_ZVAL(entry); array_init(entry); - add_assoc_long(entry, "key", bucket->key); + /* bucket->key is unsigned long */ + if (LONG_MAX >= bucket->key) { + add_assoc_long(entry, "key", bucket->key); + } else { + add_assoc_double(entry, "key", (double)bucket->key); + } add_assoc_bool(entry, "is_dir", bucket->is_dir); add_assoc_stringl(entry, "realpath", bucket->realpath, bucket->realpath_len, 1); add_assoc_long(entry, "expires", bucket->expires); diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt index a476063d66..92d6fc5b2a 100644 --- a/ext/standard/tests/file/realpath_cache.phpt +++ b/ext/standard/tests/file/realpath_cache.phpt @@ -19,7 +19,7 @@ echo "Done\n"; int(%d) array(4) { ["key"]=> - int(%i) + %s(%d) ["is_dir"]=> bool(true) ["realpath"]=> diff --git a/ext/standard/tests/file/realpath_cache_win32.phpt b/ext/standard/tests/file/realpath_cache_win32.phpt index 16fc412b09..a4c663f6d1 100644 --- a/ext/standard/tests/file/realpath_cache_win32.phpt +++ b/ext/standard/tests/file/realpath_cache_win32.phpt @@ -19,7 +19,7 @@ echo "Done\n"; int(%d) array(8) { ["key"]=> - int(%d) + %s(%d) ["is_dir"]=> bool(true) ["realpath"]=>