Merge branch 'master' of git.php.net:php-src

This commit is contained in:
andrey 2012-04-30 17:31:06 +02:00
commit 2ab5b57cd4
26 changed files with 599 additions and 362 deletions

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,9 @@
#endif
#include "zend_language_scanner_defs.h"
#ifdef PHP_WIN32
# include <Winuser.h>
#endif
#include <errno.h>
#include "zend.h"
#include "zend_alloc.h"
@ -905,7 +907,11 @@ static void zend_scan_escape_string(zval *zendlval, char *str, int len, char quo
zendlval->value.str.len--;
break;
case 'e':
#ifdef PHP_WIN32
*t++ = VK_ESCAPE;
#else
*t++ = '\e';
#endif
zendlval->value.str.len--;
break;
case '"':

View File

@ -1,4 +1,4 @@
/* Generated by re2c 0.13.5 on Mon Apr 9 18:25:45 2012 */
/* Generated by re2c 0.13.5 on Mon Apr 30 10:33:28 2012 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {

View File

@ -2,9 +2,34 @@
unixtojd()
--SKIPIF--
<?php include 'skipif.inc'; ?>
--ENV--
TZ=UTC
--FILE--
<?php
// this line has no impact on test output on Windows
putenv('TZ=UTC');
// getenv('TZ') returns 'UTC' here
// putenv (basic_functions.c) does call tzset() when the env var being put is 'TZ'
// -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the value of 'TZ' returns 'UTC'
// putting a call to date_default_timezone_set() here doesn't help
//
// on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section
// -since putenv() is written to call tzset() when env var is TZ, I assume that putenv("TZ=UTC") is intended to work
// and should work on all platforms(including Windows).
// easter_date.phpt passes
// -doesn't use --ENV-- section
// -uses --INI-- section with date.timezone=UTC
// -uses putenv('TZ=UTC')
// date.timezone=UTC
// -if ommitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning
// -easter_date() calls mktime() and localtime()
// -whereas unixtojd(1000000000) calls localtime(1000000000)
// -if ommitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG
//
// unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours
// -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly)
// but returns -1 day from expected because its input is -1 from expected
echo unixtojd(40000). "\n";
echo unixtojd(1000000000). "\n";
echo unixtojd(1152459009). "\n";

View File

@ -1,7 +1,13 @@
--TEST--
Bug #52209 (INPUT_ENV returns NULL for set variables (CLI))
--SKIPIF--
<?php if (!extension_loaded("filter") || !empty($_ENV['PWD'])) die("skip"); ?>
<?php
/* This test makes no sense on windows as an empty variable
would never show up in the "set" list. Which means, it's
always undefined in PHP. */
if(substr(PHP_OS, 0, 3) == "WIN") die("skip Not for Windows");
if (!extension_loaded("filter") || !empty($_ENV['PWD'])) die("skip");
?>
--INI--
variables_order=GPCSE
--FILE--

View File

@ -1,7 +1,10 @@
--TEST--
Bug #42596 (session.save_path MODE option will not set "write" bit for group or world)
--SKIPIF--
<?php include('skipif.inc'); ?>
<?php
if(substr(PHP_OS, 0, 3) == "WIN") die("skip not for Windows");
include('skipif.inc');
?>
--INI--
session.use_cookies=0
session.cache_limiter=

View File

@ -0,0 +1,19 @@
--TEST--
session rfc1867 invalid settings
--INI--
session.upload_progress.freq=-1
error_log=
--SKIPIF--
<?php
include('skipif.inc');
if(substr(PHP_OS, 0, 3) != "WIN")
die("skip windows only test");
?>
--FILE--
<?php
var_dump(ini_get("session.upload_progress.freq"));
?>
--EXPECTF--
Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s
string(2) "1%"
PHP Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s

View File

@ -4,7 +4,11 @@ session rfc1867 invalid settings
session.upload_progress.freq=-1
error_log=
--SKIPIF--
<?php include('skipif.inc'); ?>
<?php
include('skipif.inc');
if(substr(PHP_OS, 0, 3) == "WIN")
die("skip Not for Windows");
?>
--FILE--
<?php
var_dump(ini_get("session.upload_progress.freq"));

View File

@ -0,0 +1,19 @@
--TEST--
session rfc1867 invalid settings 2
--INI--
session.upload_progress.freq=200%
error_log=
--SKIPIF--
<?php
include('skipif.inc');
if(substr(PHP_OS, 0, 3) != "WIN")
die("skip windows only test");
?>
--FILE--
<?php
var_dump(ini_get("session.upload_progress.freq"));
?>
--EXPECTF--
Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s
string(2) "1%"
PHP Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s

View File

@ -4,7 +4,11 @@ session rfc1867 invalid settings 2
session.upload_progress.freq=200%
error_log=
--SKIPIF--
<?php include('skipif.inc'); ?>
<?php
include('skipif.inc');
if(substr(PHP_OS, 0, 3) == "WIN")
die("skip Not for Windows");
?>
--FILE--
<?php
var_dump(ini_get("session.upload_progress.freq"));

View File

@ -23,7 +23,7 @@ class MySession2 extends SessionHandler {
public function open($path, $name) {
if (!$path) {
$path = '/tmp';
$path = sys_get_temp_dir();
}
$this->path = $path . '/u_sess_' . $name;
return true;

View File

@ -23,7 +23,7 @@ class MySession2 implements SessionHandlerInterface {
public function open($path, $name) {
if (!$path) {
$path = '/tmp';
$path = sys_get_temp_dir();
}
$this->path = $path . '/u_sess_' . $name;
return true;

View File

@ -32,7 +32,7 @@ class MySession2 implements MySessionHandlerInterface {
public function open($path, $name) {
if (!$path) {
$path = '/tmp';
$path = sys_get_temp_dir();
}
$this->path = $path . '/u_sess_' . $name;
return true;

View File

@ -0,0 +1,37 @@
--TEST--
SQLite3::open error test
--SKIPIF--
<?php
if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test');
}
require_once(__DIR__ . '/skipif.inc');
?>
--FILE--
<?php
$sysroot = exec('echo %systemroot%');
$icacls = "$sysroot\\System32\\icacls.exe";
$user = get_current_user();
$unreadable = __DIR__ . '/unreadable.db';
touch($unreadable);
$cmd = $icacls . ' ' . $unreadable . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)';
exec($cmd);
try {
$db = new SQLite3($unreadable);
} catch (Exception $e) {
echo $e . "\n";
}
echo "Done\n";
$cmd = $icacls . ' ' . $unreadable . ' /grant ' . $user . ':(F,M,R,RX,W)';
exec($cmd);
unlink($unreadable);
?>
--EXPECTF--
exception 'Exception' with message 'Unable to open database: %s' in %ssqlite3_15_open_error-win.php:%d
Stack trace:
#0 %ssqlite3_15_open_error-win.php(%d): SQLite3->__construct('%s')
#1 {main}
Done

View File

@ -2,6 +2,9 @@
SQLite3::open error test
--SKIPIF--
<?php
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
die('skip non windows test');
}
require_once(__DIR__ . '/skipif.inc');
if (posix_geteuid() == 0) {
die('SKIP Cannot run test as root.');

View File

@ -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);
}

View File

@ -719,7 +719,8 @@ PHP_FUNCTION(unpack)
case 'Z': {
/* Z will strip everything after the first null character */
char pad = '\0';
int len = inputlen - inputpos; /* Remaining string */
int s,
len = inputlen - inputpos; /* Remaining string */
/* If size was given take minimum of len and size */
if ((size >= 0) && (len > size)) {
@ -729,7 +730,7 @@ PHP_FUNCTION(unpack)
size = len;
/* Remove everything after the first null */
int s = 0;
s = 0;
while (s++ <= len) {
if (input[inputpos + s] == pad)
break;

View File

@ -8,6 +8,7 @@ skipif();
--FILE--
<?php
include_once __DIR__ . '/common.inc';
fix_acls();
$iteration = array(
PHPT_ACL_READ => false,

View File

@ -8,6 +8,7 @@ skipif();
--FILE--
<?php
include_once __DIR__ . '/common.inc';
fix_acls();
$iteration = array(
PHPT_ACL_READ => true,

View File

@ -8,6 +8,7 @@ skipif();
--FILE--
<?php
include_once __DIR__ . '/common.inc';
fix_acls();
$iteration = array(
'tiny.exe' => true,

View File

@ -10,6 +10,7 @@ skipif();
--FILE--
<?php
include_once __DIR__ . '/common.inc';
fix_acls();
$iteration = array(
PHPT_ACL_READ => true,

View File

@ -25,16 +25,39 @@ function get_username(){
$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 = 'c:\\Windows\\System32\\icacls.exe';
$icacls = get_icacls();
$user = get_username();
$path_escaped = '"' . $path . '"';
$perm_entry = array();

View File

@ -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

View File

@ -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) {

View File

@ -662,7 +662,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
int php_optind = 1, orig_optind = 1;
char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
char *arg_free=NULL, **arg_excp=&arg_free;
char *script_file=NULL;
char *script_file=NULL, *translated_path = NULL;
int interactive=0;
int lineno = 0;
const char *param_error=NULL;
@ -927,8 +927,13 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
if (script_file) {
if (cli_seek_file_begin(&file_handle, script_file, &lineno TSRMLS_CC) != SUCCESS) {
goto err;
} else {
char real_path[MAXPATHLEN];
if (VCWD_REALPATH(script_file, real_path)) {
translated_path = strdup(real_path);
}
script_filename = script_file;
}
script_filename = script_file;
} else {
/* We could handle PHP_MODE_PROCESS_STDIN in a different manner */
/* here but this would make things only more complicated. And it */
@ -947,7 +952,7 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
SG(request_info).argc=argc-php_optind+1;
arg_excp = argv+php_optind-1;
arg_free = argv[php_optind-1];
SG(request_info).path_translated = (char*)file_handle.filename;
SG(request_info).path_translated = translated_path? translated_path: (char*)file_handle.filename;
argv[php_optind-1] = (char*)file_handle.filename;
SG(request_info).argv=argv+php_optind-1;

View File

@ -0,0 +1,22 @@
--TEST--
Bug #61546 (functions related to current script failed when chdir() in cli sapi)
--FILE--
<?php
$php = getenv("TEST_PHP_EXECUTABLE");
$test_code = <<<PHP
<?php
chdir('..');
var_dump(get_current_user() != "");
chdir('..');
var_dump(getmyinode() != false);
var_dump(getlastmod() != false);
PHP;
file_put_contents("bug61546_sub.php", $test_code);
system($php . ' -n bug61546_sub.php');
unlink("bug61546_sub.php");
?>
--EXPECT--
bool(true)
bool(true)
bool(true)