]> granicus.if.org Git - php/commitdiff
Fix bug ext\standard\tests\file\realpath_cache_win32.phpt fails
authorAnatoliy Belsky <ab@php.net>
Thu, 10 May 2012 13:27:44 +0000 (15:27 +0200)
committerAnatoliy Belsky <ab@php.net>
Thu, 10 May 2012 13:27:44 +0000 (15:27 +0200)
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.

ext/standard/filestat.c
ext/standard/tests/file/realpath_cache.phpt
ext/standard/tests/file/realpath_cache_win32.phpt

index 94a7b89b875c1086c7022b812faa031ed039bc02..349526ecfdde3d34579891b76cf49f02fc4266ce 100644 (file)
@@ -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);
index a476063d66411b2d5db39c8047890b87e45978aa..92d6fc5b2a37e52ccea8549244bd5b44d41eaac0 100644 (file)
@@ -19,7 +19,7 @@ echo "Done\n";
 int(%d)
 array(4) {
   ["key"]=>
-  int(%i)
+  %s(%d)
   ["is_dir"]=>
   bool(true)
   ["realpath"]=>
index 16fc412b09abc2c6995941febd5c545edaa83dda..a4c663f6d11baf4c8ce7a8d280b8582c945c8fda 100644 (file)
@@ -19,7 +19,7 @@ echo "Done\n";
 int(%d)
 array(8) {
   ["key"]=>
-  int(%d)
+  %s(%d)
   ["is_dir"]=>
   bool(true)
   ["realpath"]=>