diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-05-28 16:52:15 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-05-28 16:52:15 +0200 |
| commit | 01c525f668ecff08bea21c4ff22745b8f77e8c3a (patch) | |
| tree | 07ebb675549d7a8ceb905676e4894151122321ac /ext/standard | |
| parent | d4d61a2bcb9975c8aeddbc6603211064174087a9 (diff) | |
| download | php-01c525f668ecff08bea21c4ff22745b8f77e8c3a.tar.gz | |
Imported Upstream version 5.4.4~rc1upstream/5.4.4_rc1
Diffstat (limited to 'ext/standard')
36 files changed, 353 insertions, 73 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index d1f302994..94c5e7e6e 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1058,7 +1058,6 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive char *string_key; uint string_key_len; ulong num_key; - HashPosition pos; /* Set up known arguments */ args[1] = &key; @@ -1067,15 +1066,14 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive Z_ADDREF_P(userdata); } - zend_hash_internal_pointer_reset_ex(target_hash, &pos); - BG(array_walk_fci).retval_ptr_ptr = &retval_ptr; BG(array_walk_fci).param_count = userdata ? 3 : 2; BG(array_walk_fci).params = args; BG(array_walk_fci).no_separation = 0; - + /* Iterate through hash */ - while (!EG(exception) && zend_hash_get_current_data_ex(target_hash, (void **)&args[0], &pos) == SUCCESS) { + zend_hash_internal_pointer_reset(target_hash); + while (!EG(exception) && zend_hash_get_current_data(target_hash, (void **)&args[0]) == SUCCESS) { if (recursive && Z_TYPE_PP(args[0]) == IS_ARRAY) { HashTable *thash; zend_fcall_info orig_array_walk_fci; @@ -1107,7 +1105,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive MAKE_STD_ZVAL(key); /* Set up the key */ - switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 0, &pos)) { + switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 0, NULL)) { case HASH_KEY_IS_LONG: Z_TYPE_P(key) = IS_LONG; Z_LVAL_P(key) = num_key; @@ -1135,7 +1133,7 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive zval_ptr_dtor(&key); key = NULL; } - zend_hash_move_forward_ex(target_hash, &pos); + zend_hash_move_forward(target_hash); } if (userdata) { diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index bfe1abd01..142ca9bdc 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -1208,7 +1208,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/iptc.c b/ext/standard/iptc.c index bf01e74ba..43dc372bc 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -336,13 +336,13 @@ PHP_FUNCTION(iptcparse) len = (((unsigned short) buffer[ inx ])<<8) | (unsigned short)buffer[ inx+1 ]; inx += 2; } - - snprintf(key, sizeof(key), "%d#%03d", (unsigned int) dataset, (unsigned int) recnum); - - if ((len > str_len) || (inx + len) > str_len) { + + if ((len < 0) || (len > str_len) || (inx + len) > str_len) { break; } + snprintf(key, sizeof(key), "%d#%03d", (unsigned int) dataset, (unsigned int) recnum); + if (tagsfound == 0) { /* found the 1st tag - initialize the return array */ array_init(return_value); } diff --git a/ext/standard/math.c b/ext/standard/math.c index 302fbdae4..65187f6fa 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -37,7 +37,7 @@ static inline int php_intlog10abs(double value) { int result; value = fabs(value); - if (value < 1e-8 || value > 1e23) { + if (value < 1e-8 || value > 1e22) { result = (int)floor(log10(value)); } else { static const double values[] = { @@ -46,7 +46,7 @@ static inline int php_intlog10abs(double value) { 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; /* Do a binary search with 5 steps */ - result = 16; + result = 15; if (value < values[result]) { result -= 8; } else { diff --git a/ext/standard/pack.c b/ext/standard/pack.c index faf0a2b29..65a5c00cc 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -758,16 +758,14 @@ PHP_FUNCTION(unpack) case 'i': case 'I': { - long v = 0; + long v; int issigned = 0; if (type == 'i') { issigned = input[inputpos + (machine_little_endian ? (sizeof(int) - 1) : 0)] & 0x80; - } else if (sizeof(long) > 4 && (input[inputpos + machine_endian_long_map[3]] & 0x80) == 0x80) { - v = ~INT_MAX; } - v |= php_unpack(&input[inputpos], sizeof(int), issigned, int_map); + v = php_unpack(&input[inputpos], sizeof(int), issigned, int_map); add_assoc_long(return_value, n, v); break; } diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index a831dd1c1..b51aaa219 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -263,6 +263,20 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch long fildes_ori; int dtablesize; + if (strcmp(sapi_module.name, "cli")) { + if (options & REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Direct access to file descriptors is only available from command-line PHP"); + } + return NULL; + } + + if ((options & STREAM_OPEN_FOR_INCLUDE) && !PG(allow_url_include) ) { + if (options & REPORT_ERRORS) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "URL file-access is disabled in the server configuration"); + } + return NULL; + } + start = &path[3]; fildes_ori = strtol(start, &end, 10); if (end == start || *end != '\0') { diff --git a/ext/standard/string.c b/ext/standard/string.c index 0aade7808..5c33232f7 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -266,6 +266,11 @@ PHP_FUNCTION(hex2bin) return; } + if (datalen % 2 != 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Hexadecimal input string must have an even length"); + RETURN_FALSE; + } + result = php_hex2bin((unsigned char *)data, datalen, &newlen); if (!result) { diff --git a/ext/standard/tests/array/bug61730.phpt b/ext/standard/tests/array/bug61730.phpt new file mode 100644 index 000000000..0fe9f2221 --- /dev/null +++ b/ext/standard/tests/array/bug61730.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #61730 (Segfault from array_walk modifying an array passed by reference) +--FILE-- +<?php +$myArray = array_fill(0, 10, 1); + +array_walk( + $myArray, + function($value, $key) use ($myArray) + { + reset($myArray); + } +); + +array_walk( + $myArray, + function($value, $key) use (&$myArray) + { + var_dump($key); + unset($myArray[$key]); + unset($myArray[$key+1]); + unset($myArray[$key+2]); + } +); + + + +print_r($myArray); +--EXPECT-- +int(0) +int(4) +int(8) +Array +( + [3] => 1 + [7] => 1 +) diff --git a/ext/standard/tests/file/bug61961.phpt b/ext/standard/tests/file/bug61961.phpt new file mode 100644 index 000000000..ff0279a36 --- /dev/null +++ b/ext/standard/tests/file/bug61961.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #61961 (file_get_content leaks when access empty file with max length) +--FILE-- +<?php +$tmp_empty_file = __FILE__ . ".tmp"; +file_put_contents($tmp_empty_file, ""); + +var_dump(file_get_contents($tmp_empty_file, NULL, NULL, NULL, 10)); +unlink($tmp_empty_file); +?> +==DONE== +--EXPECT-- +string(0) "" +==DONE==
\ No newline at end of file diff --git a/ext/standard/tests/file/popen_pclose_error-win32.phpt b/ext/standard/tests/file/popen_pclose_error-win32.phpt index 486f369c9..9f9593c64 100644 --- a/ext/standard/tests/file/popen_pclose_error-win32.phpt +++ b/ext/standard/tests/file/popen_pclose_error-win32.phpt @@ -17,7 +17,7 @@ if (PHP_DEBUG) die("skip Not Valid for debug builds"); * Description: Closes process file pointer. */ $file_path = dirname(__FILE__); -echo "*** Testing for error conditions ***\n"; +echo "*** Testing for error conditions ***" . PHP_EOL; var_dump( popen() ); // Zero Arguments var_dump( popen("abc.txt") ); // Single Argument var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument @@ -26,7 +26,7 @@ $file_handle = fopen($file_path."/popen.tmp", "w"); var_dump( pclose($file_handle, $file_handle) ); pclose($file_handle); var_dump( pclose(1) ); -echo "\n--- Done ---"; +echo PHP_EOL . PHP_EOL . "--- Done ---"; ?> --CLEAN-- <?php @@ -54,5 +54,6 @@ bool(false) Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d bool(false) + --- Done ---'abc.txt' is not recognized as an internal or external command, operable program or batch file. diff --git a/ext/standard/tests/file/realpath_cache.phpt b/ext/standard/tests/file/realpath_cache.phpt index a476063d6..92d6fc5b2 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 16fc412b0..a4c663f6d 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"]=> diff --git a/ext/standard/tests/file/rename_variation13-win32.phpt b/ext/standard/tests/file/rename_variation13-win32.phpt Binary files differindex b4085c8a5..dc44b358f 100644 --- a/ext/standard/tests/file/rename_variation13-win32.phpt +++ b/ext/standard/tests/file/rename_variation13-win32.phpt diff --git a/ext/standard/tests/file/windows_acls/bug44859.phpt b/ext/standard/tests/file/windows_acls/bug44859.phpt index bb22a5cd8..952b6eb4c 100644 --- a/ext/standard/tests/file/windows_acls/bug44859.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859.phpt @@ -8,6 +8,7 @@ skipif(); --FILE-- <?php include_once __DIR__ . '/common.inc'; +fix_acls(); $iteration = array( PHPT_ACL_READ => false, diff --git a/ext/standard/tests/file/windows_acls/bug44859_2.phpt b/ext/standard/tests/file/windows_acls/bug44859_2.phpt index 3cc4ed1ba..d741156ba 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_2.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_2.phpt @@ -8,6 +8,7 @@ skipif(); --FILE-- <?php include_once __DIR__ . '/common.inc'; +fix_acls(); $iteration = array( PHPT_ACL_READ => true, diff --git a/ext/standard/tests/file/windows_acls/bug44859_3.phpt b/ext/standard/tests/file/windows_acls/bug44859_3.phpt index 7300112fc..ed57abba0 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_3.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_3.phpt @@ -8,6 +8,7 @@ skipif(); --FILE-- <?php include_once __DIR__ . '/common.inc'; +fix_acls(); $iteration = array( 'tiny.exe' => true, diff --git a/ext/standard/tests/file/windows_acls/bug44859_4.phpt b/ext/standard/tests/file/windows_acls/bug44859_4.phpt index c1768d02e..954c1004a 100644 --- a/ext/standard/tests/file/windows_acls/bug44859_4.phpt +++ b/ext/standard/tests/file/windows_acls/bug44859_4.phpt @@ -10,6 +10,7 @@ skipif(); --FILE-- <?php include_once __DIR__ . '/common.inc'; +fix_acls(); $iteration = array( PHPT_ACL_READ => true, diff --git a/ext/standard/tests/file/windows_acls/common.inc b/ext/standard/tests/file/windows_acls/common.inc index c4276014a..26fadf31f 100644 --- a/ext/standard/tests/file/windows_acls/common.inc +++ b/ext/standard/tests/file/windows_acls/common.inc @@ -19,15 +19,45 @@ function skipif() { } function get_username(){ - return getenv('USERNAME'); + $user = getenv('USERNAME'); + + if (!$user) { + $user = get_current_user(); + } + + if (!$user) { + $user = exec('echo %USERNAME%'); + } + + return $user; } function get_domainname() { - return getenv('USERDOMAIN'); + $domain = getenv('USERDOMAIN'); + + return $domain; +} + +function get_icacls() +{ + $sysroot = exec('echo %SYSTEMROOT%'); + + return "$sysroot\\System32\\icacls.exe"; +} + +function fix_acls() { + $user = get_username(); + /* Current user needs to be owner of the test files. As well + all the other users having acls on the files must loose them. + The following fixes this just partially, as dynamically reading + all the users having acls on a file could be sophisticated. */ + exec(get_icacls() . ' . /setowner $user /T /L /Q 2> nul'); + exec(get_icacls() . ' . /remove:g Administrators /T /L /Q 2> nul'); } function icacls_set($path, $mode, $perm) { + $icacls = get_icacls(); $user = get_username(); $path_escaped = '"' . $path . '"'; $perm_entry = array(); @@ -38,7 +68,7 @@ function icacls_set($path, $mode, $perm) { if ($perm & PHPT_ACL_FULL) $perm_entry[] = 'F'; // Deny all - $cmd = 'icacls ' . $path_escaped . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)'; + $cmd = $icacls . ' ' . $path_escaped . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)'; exec($cmd); if ($perm & PHPT_ACL_NONE) { @@ -47,11 +77,9 @@ function icacls_set($path, $mode, $perm) { permission for the USER. Just granting permission doesn't remove the previously denied permission. */ - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:d'; - $cmd .= ' ' . $user; + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; exec($cmd); - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:g'; - $cmd .= ' ' . $user; + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; exec($cmd); return; } @@ -64,7 +92,7 @@ function icacls_set($path, $mode, $perm) { // Deny all - $cmd = 'icacls ' . $path_escaped . ' /deny ' . $user . ':(F,M,R,RX,W)'; + $cmd = $icacls . ' ' . $path_escaped . ' /deny ' . $user . ':(F,M,R,RX,W)'; exec($cmd); /* @@ -72,11 +100,9 @@ function icacls_set($path, $mode, $perm) { permission for the USER. Just granting permission doesn't remove the previously denied permission. */ - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:d'; - $cmd .= ' ' . $user; + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; exec($cmd); - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:g'; - $cmd .= ' ' . $user; + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; exec($cmd); @@ -91,15 +117,12 @@ function icacls_set($path, $mode, $perm) { permission for the USER. Just granting permission doesn't remove the previously denied permission. */ - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:d'; - $cmd .= ' ' . get_username(); + $cmd = $icacls . ' ' . $path_escaped . ' /remove:d ' . $user; exec($cmd); - $cmd = 'icacls ' . $path_escaped . ' /' . 'remove:g'; - $cmd .= ' ' . get_username(); + $cmd = $icacls . ' ' . $path_escaped . ' /remove:g ' . $user; exec($cmd); - $cmd = 'icacls ' . $path_escaped . ' /' . $mode; - $cmd .= ' ' . get_username(); + $cmd = $icacls . ' ' . $path_escaped . ' /' . $mode . ' ' . $user; $cmd .= ':' . '(' . implode($perm_entry, ',') . ')'; exec($cmd); } diff --git a/ext/standard/tests/file/windows_links/bug48746.phpt b/ext/standard/tests/file/windows_links/bug48746.phpt index 6c88c6319..5978e7f7f 100644 --- a/ext/standard/tests/file/windows_links/bug48746.phpt +++ b/ext/standard/tests/file/windows_links/bug48746.phpt @@ -1,7 +1,7 @@ --TEST--
Bug#48746 - Junction not working properly
---CREDIT--
+--CREDITS--
Venkat Raman Don (don.raman@microsoft.com)
--SKIPIF--
@@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com) if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
-$cmd = "mklink.exe /?";
+include_once __DIR__ . '/common.inc';
+$cmd = "mklink /?";
$ret = @exec($cmd, $output, $return_val);
if (count($output) == 0) {
die("mklink.exe not found in PATH");
@@ -17,13 +18,15 @@ if (count($output) == 0) { ?>
--FILE--
<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
$old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory";
mkdir($dirname, 0700, true);
chdir(__DIR__ . "\\mnt\\test");
$drive = substr(__DIR__, 0, 2);
$pathwithoutdrive = substr(__DIR__, 2);
-$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
$fullpath = "mounted_volume" . $pathwithoutdrive;
exec("mklink /j mklink_junction directory", $output, $ret_val);
diff --git a/ext/standard/tests/file/windows_links/bug48746_1.phpt b/ext/standard/tests/file/windows_links/bug48746_1.phpt index ca8450a89..a4277a47a 100644 --- a/ext/standard/tests/file/windows_links/bug48746_1.phpt +++ b/ext/standard/tests/file/windows_links/bug48746_1.phpt @@ -1,7 +1,7 @@ --TEST--
Bug#48746 - Junction not working properly
---CREDIT--
+--CREDITS--
Venkat Raman Don (don.raman@microsoft.com)
--SKIPIF--
@@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com) if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
-$cmd = "mklink.exe /?";
+include_once __DIR__ . '/common.inc';
+$cmd = "mklink /?";
$ret = @exec($cmd, $output, $return_val);
if (count($output) == 0) {
die("mklink.exe not found in PATH");
@@ -17,13 +18,15 @@ if (count($output) == 0) { ?>
--FILE--
<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
$old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val);
chdir(__DIR__ . "\\mnt\\test");
$drive = substr(__DIR__, 0, 2);
$pathwithoutdrive = substr(__DIR__, 2);
-$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
$fullpath = "mounted_volume" . $pathwithoutdrive;
exec("mklink /j mklink_junction directory", $output, $ret_val);
@@ -53,4 +56,4 @@ I am included. I am included.
bool(true)
bool(true)
-bool(true) +bool(true)
diff --git a/ext/standard/tests/file/windows_links/bug48746_2.phpt b/ext/standard/tests/file/windows_links/bug48746_2.phpt index 7beed1691..509610f8a 100644 --- a/ext/standard/tests/file/windows_links/bug48746_2.phpt +++ b/ext/standard/tests/file/windows_links/bug48746_2.phpt @@ -1,7 +1,7 @@ --TEST--
Bug#48746 - Junction not working properly
---CREDIT--
+--CREDITS--
Venkat Raman Don (don.raman@microsoft.com)
--SKIPIF--
@@ -9,21 +9,24 @@ Venkat Raman Don (don.raman@microsoft.com) if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
+include_once __DIR__ . '/common.inc';
$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
if (strpos($ret, 'privilege')) {
die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
}
-unlink('mklink bug48746_tmp.lnk');
+unlink('bug48746_tmp.lnk');
?>
--FILE--
<?php
+include_once __DIR__ . '/common.inc';
+$mountvol = get_mountvol();
$old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val);
chdir(__DIR__ . "\\mnt\\test");
$drive = substr(__DIR__, 0, 2);
$pathwithoutdrive = substr(__DIR__, 2);
-$ret = exec("mountvol " . $drive . " /L", $output, $ret_val);
+$ret = exec($mountvol . " " . $drive . " /L", $output, $ret_val);
exec("mklink /j mounted_volume " . $ret, $output, $ret_val);
$fullpath = "mounted_volume" . $pathwithoutdrive;
exec("mklink /j mklink_junction directory", $output, $ret_val);
@@ -63,4 +66,4 @@ Array [1] => ..
[2] => a.php
[3] => b.php
-) +)
diff --git a/ext/standard/tests/file/windows_links/bug48746_3.phpt b/ext/standard/tests/file/windows_links/bug48746_3.phpt index a0dcbdc02..98e81787b 100644 --- a/ext/standard/tests/file/windows_links/bug48746_3.phpt +++ b/ext/standard/tests/file/windows_links/bug48746_3.phpt @@ -1,7 +1,7 @@ --TEST--
Bug#48746 - Junction not working properly
---CREDIT--
+--CREDITS--
Venkat Raman Don (don.raman@microsoft.com)
--SKIPIF--
@@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com) if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
-$ret = exec('junction /? 2>&1', $out);
+include_once __DIR__ . '/common.inc';
+$ret = exec(get_junction().' /? 2>&1', $out);
if (strpos($out[0], 'recognized')) {
die('skip. junction.exe not found in PATH.');
}
@@ -17,11 +18,12 @@ if (strpos($out[0], 'recognized')) { ?>
--FILE--
<?php
+include_once __DIR__ . '/common.inc';
$old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val);
chdir(__DIR__ . "\\mnt\\test");
-exec("junction junction directory", $output, $ret_val);
+exec(get_junction()." junction directory", $output, $ret_val);
file_put_contents("junction\\a.php", "<?php echo \"I am included.\n\" ?>");
file_put_contents("junction\\b.php", "<?php echo \"I am included.\n\" ?>");
include "junction/a.php";
@@ -45,4 +47,4 @@ Array [1] => ..
[2] => a.php
[3] => b.php
-) +)
diff --git a/ext/standard/tests/file/windows_links/common.inc b/ext/standard/tests/file/windows_links/common.inc new file mode 100644 index 000000000..2d4b47cd5 --- /dev/null +++ b/ext/standard/tests/file/windows_links/common.inc @@ -0,0 +1,23 @@ +<?php + +function get_sysroot() { + // usually c:\\windows, but not always + return exec('echo %SYSTEMROOT%'); +} + +function get_junction(){ + // junction.exe isn't included with Windows + // its a sysinternals tool for working with filesystem links + // see: http://technet.microsoft.com/en-us/sysinternals/bb896768 + + // install somewhere that is on %path% or added to %path% + return "junction.exe"; +} + +function get_mountvol() { + $sysroot = get_sysroot(); + + return "$sysroot\\System32\\mountvol.exe"; +} + +?> diff --git a/ext/standard/tests/general_functions/bug44295-win.phpt b/ext/standard/tests/general_functions/bug44295-win.phpt new file mode 100644 index 000000000..d210a54d5 --- /dev/null +++ b/ext/standard/tests/general_functions/bug44295-win.phpt @@ -0,0 +1,29 @@ +--TEST-- +user defined error handler + set_error_handling(EH_THROW) +--SKIPIF-- +<?php + if(substr(PHP_OS, 0, 3) != "WIN") die("skip Windows only"); + if (!extension_loaded("spl") || is_dir('c:\\not\\exists\\here')) die("skip"); +?> +--FILE-- +<?php +$dir = 'c:\\not\\exists\\here'; + +set_error_handler('my_error_handler'); +function my_error_handler() {$a = func_get_args(); print "in error handler\n"; } + +try { + print "before\n"; + $iter = new DirectoryIterator($dir); + print get_class($iter) . "\n"; + print "after\n"; +} catch (Exception $e) { + print "in catch: ".$e->getMessage()."\n"; +} +?> +==DONE== +<?php exit(0); ?> +--EXPECT-- +before +in catch: DirectoryIterator::__construct(c:\not\exists\here,c:\not\exists\here): The system cannot find the path specified. (code: 3) +==DONE== diff --git a/ext/standard/tests/general_functions/bug44295.phpt b/ext/standard/tests/general_functions/bug44295.phpt index 9c1271991..a18471919 100644 --- a/ext/standard/tests/general_functions/bug44295.phpt +++ b/ext/standard/tests/general_functions/bug44295.phpt @@ -1,7 +1,10 @@ --TEST-- user defined error handler + set_error_handling(EH_THROW) --SKIPIF-- -<?php if (!extension_loaded("spl") || is_dir('/this/path/does/not/exist')) die("skip"); ?> +<?php + if(substr(PHP_OS, 0, 3) == "WIN") die("skip Not for Windows"); + if (!extension_loaded("spl") || is_dir('/this/path/does/not/exist')) die("skip"); +?> --FILE-- <?php $dir = '/this/path/does/not/exist'; diff --git a/ext/standard/tests/general_functions/bug49847.phpt b/ext/standard/tests/general_functions/bug49847.phpt index 6312d03c0..112592d6e 100644 --- a/ext/standard/tests/general_functions/bug49847.phpt +++ b/ext/standard/tests/general_functions/bug49847.phpt @@ -9,7 +9,7 @@ if ($iswin) { $s = str_repeat(' ', 4097); $s .= '1'; file_put_contents($f, $s); - exec('more ' . $f, $output); + exec('type ' . $f, $output); } else { exec("printf %4098d 1", $output); } diff --git a/ext/standard/tests/misc/time_sleep_until_basic.phpt b/ext/standard/tests/misc/time_sleep_until_basic.phpt index 9ae912881..05cc0e6de 100644 --- a/ext/standard/tests/misc/time_sleep_until_basic.phpt +++ b/ext/standard/tests/misc/time_sleep_until_basic.phpt @@ -13,7 +13,19 @@ Michele Orselli mo@ideato.it <?php $time = microtime(true) + 2; var_dump(time_sleep_until( (int)$time )); - var_dump(microtime(true) >= (int)$time); + $now = microtime(true); + if(substr(PHP_OS, 0, 3) == 'WIN' ) { + // on windows, time_sleep_until has millisecond accuracy while microtime() is accurate + // to 10th of a second. this means there can be up to a .9 millisecond difference + // which will fail this test. this test randomly fails on Windows and this is the cause. + // + // fix: round to nearest millisecond + // passes for up to .5 milliseconds less, fails for more than .5 milliseconds + // should be fine since time_sleep_until() on Windows is accurate to the + // millisecond(.5 rounded up is 1 millisecond) + $now = round($now, 3); + } + var_dump($now >= (int)$time); ?> --EXPECT-- bool(true) diff --git a/ext/standard/tests/streams/bug60106.phpt b/ext/standard/tests/streams/bug60106.phpt index c9e94e767..1b36af1a3 100644 --- a/ext/standard/tests/streams/bug60106.phpt +++ b/ext/standard/tests/streams/bug60106.phpt @@ -7,13 +7,17 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) ?> --FILE-- <?php - error_reporting(E_ALL | E_NOTICE); - stream_socket_server("unix:///tmp/" . str_repeat("a", 4096)); +error_reporting(E_ALL | E_NOTICE); +$socket_file = "/tmp/" . str_repeat("a", 512); +function get_truncated_socket_filename($errno, $errmsg, $file, $line) { + global $socket_file; + print_r ($errmsg); + preg_match("#maximum allowed length of (\d+) bytes#", $errmsg, $matches); + $socket_file = substr($socket_file, 0, intval($matches[1]) - 1); +} +set_error_handler("get_truncated_socket_filename", E_NOTICE); +stream_socket_server("unix://" . $socket_file); +unlink($socket_file); ?> -===DONE=== --EXPECTF-- -Notice: stream_socket_server(): socket path exceeded the maximum allowed length of %d bytes and was truncated in %s on line %d - -Warning: stream_socket_server(): unable to connect to unix:///tmp/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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--git a/ext/standard/tests/streams/bug61115-1.phpt b/ext/standard/tests/streams/bug61115-1.phpt index cfed64f03..89374e735 100644 --- a/ext/standard/tests/streams/bug61115-1.phpt +++ b/ext/standard/tests/streams/bug61115-1.phpt @@ -8,4 +8,4 @@ stream_context_get_options($fileResourceTemp); ftruncate($fileResourceTemp, PHP_INT_MAX); ?> --EXPECTF-- -Fatal error: Allowed memory size of %d bytes exhausted (tried to allocate %d bytes) in %s on line %d +Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d diff --git a/ext/standard/tests/streams/bug61371-win.phpt b/ext/standard/tests/streams/bug61371-win.phpt new file mode 100644 index 000000000..dc7053044 --- /dev/null +++ b/ext/standard/tests/streams/bug61371-win.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #61371: stream_context_create() causes memory leaks on use streams_socket_create +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +--FILE-- +<?php +function test($doFclose) { +$previous = null; +$current = null; +for($test=1;$test<=3;$test++) { + $current = memory_get_usage(true); + if (!is_null($previous)) { + var_dump($previous == $current); + } + $previous = $current; + echo 'memory: '.round($current / 1024, 0)."kb\n"; + for($i=0;$i<=100;$i++) { + $context = stream_context_create(array()); + $stream = stream_socket_client('udp://127.0.0.1:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); + if ($doFclose) fclose($stream); + unset($context); + unset($stream); + unset($errno); + unset($errstr); + } +} +} + +test(true); +test(false); +?> +--EXPECTF-- +memory: %dkb +bool(true) +memory: %dkb +bool(true) +memory: %dkb +memory: %dkb +bool(true) +memory: %dkb +bool(true) +memory: %dkb diff --git a/ext/standard/tests/streams/bug61371.phpt b/ext/standard/tests/streams/bug61371.phpt index 7fbfa56ba..7c64d1d30 100644 --- a/ext/standard/tests/streams/bug61371.phpt +++ b/ext/standard/tests/streams/bug61371.phpt @@ -1,5 +1,10 @@ --TEST-- Bug #61371: stream_context_create() causes memory leaks on use streams_socket_create +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip non windows test'); +} --FILE-- <?php function test($doFclose) { diff --git a/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt b/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt new file mode 100644 index 000000000..32756d761 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_line_NUL_delimiter.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #60455: stream_get_line and \0 as a delimiter +--FILE-- +<?php +class TestStream { + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + if ($this->s++ == 0) + return "a\0"; + + return ""; + } + function stream_eof() { + return $this->s >= 2; + } + +} + +stream_wrapper_register("test", "TestStream"); + +$f = fopen("test://", "r"); +var_dump(stream_get_line($f, 100, "\0")); +--EXPECT-- +string(1) "a" diff --git a/ext/standard/tests/strings/bug38770.phpt b/ext/standard/tests/strings/bug38770.phpt index 417794cd2..1821639ac 100644 --- a/ext/standard/tests/strings/bug38770.phpt +++ b/ext/standard/tests/strings/bug38770.phpt @@ -7,7 +7,7 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); --FILE-- <?php -foreach (array('N','I','l') as $v) { +foreach (array('N','l') as $v) { print_r(unpack($v, pack($v, -30000))); } @@ -22,8 +22,4 @@ Array ( [1] => -30000 ) -Array -( - [1] => -30000 -) Done diff --git a/ext/standard/tests/strings/bug61660.phpt b/ext/standard/tests/strings/bug61660.phpt new file mode 100644 index 000000000..010ea47e9 --- /dev/null +++ b/ext/standard/tests/strings/bug61660.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #61660: bin2hex(hex2bin($data)) != $data +--FILE-- +<?php + +var_dump(hex2bin('123')); + +?> +--EXPECTF-- +Warning: hex2bin(): Hexadecimal input string must have an even length in %s on line %d +bool(false) diff --git a/ext/standard/tests/strings/bug61764.phpt b/ext/standard/tests/strings/bug61764.phpt new file mode 100644 index 000000000..dc44f25b3 --- /dev/null +++ b/ext/standard/tests/strings/bug61764.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #61764: 'I' unpacks n as signed if n > 2^31-1 on LP64 +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); +--FILE-- +<?php +//expected -30000 mod 2^32 = 4294937296, and not -30000 +//because we can represent 4294937296 with our PHP int type +print_r(unpack('I', pack('L', -30000))); +--EXPECT-- +Array +( + [1] => 4294937296 +) diff --git a/ext/standard/tests/strings/htmlentities15.phpt b/ext/standard/tests/strings/htmlentities15.phpt index 54c1b0601..e5729f997 100644 --- a/ext/standard/tests/strings/htmlentities15.phpt +++ b/ext/standard/tests/strings/htmlentities15.phpt @@ -11,7 +11,7 @@ if (!$result || preg_match('/koi8/i', setlocale(LC_CTYPE, 0)) == 0) { die("skip setlocale() failed\n"); } ?> ---COMMENT-- +--DESCRIPTION-- As of PHP 5.4, htmlentities() no longer makes replacements with numerical entities. Hence, for this input there's no substitution. --FILE-- |
