com php-src: Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi).: NEWS sapi/cli/php_cli.c sapi/
cli/tests/bug61546.phpt
| From: | Xinchen Hui | Date: | Mon, 30 Apr 2012 04:09:22 +0000 |
| Subject: | com php-src: Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi).: NEWS sapi/cli/php_cli.c sapi/ cli/tests/bug61546.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-68888@lists.php.net to get a copy of this message | ||
Commit: bae56a87f81b91cd815604b0f404f616b0d73c2b
Author: Xinchen Hui <laruence@php.net> Mon, 30 Apr 2012 12:09:22 +0800
Parents: 9aff3a1156efdfae7660d5b5e7a6d8b29c263722
Branches: PHP-5.3
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bae56a87f81b91cd815604b0f404f616b0d73c2b
Log:
Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi).
Bugs:
https://bugs.php.net/61546
Changed paths:
M NEWS
M sapi/cli/php_cli.c
A sapi/cli/tests/bug61546.phpt
Diff:
diff --git a/NEWS b/NEWS
index a49ecfa..7bb6cc0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,11 +2,15 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2012, PHP 5.3.12
+- CLI SAPI:
+ . Fixed bug #61546 (functions related to current script failed when chdir()
+ in cli sapi). (Laruence, reeze.xia@gmail.com)
+
- Core:
. Fixed missing bound check in iptcparse(). (chris at chiappa.net)
. Fixed bug #61764 ('I' unpacks n as signed if n > 2^31-1 on LP64). (Gustavo)
. Fixed bug #54197 ([PATH=] sections incompatibility with user_ini.filename
- set to null). (Anatoliy)
+ set to null). (Anatoliy)
- Fileinfo:
. Fixed bug #61812 (Uninitialised value used in libmagic).
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 0fbf7c8..f26db43 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -648,7 +648,7 @@ int main(int argc, char *argv[])
int orig_optind=php_optind;
char *orig_optarg=php_optarg;
char *arg_free=NULL, **arg_excp=&arg_free;
- char *script_file=NULL;
+ char *script_file=NULL, *translated_path = NULL;
int interactive=0;
volatile int module_started = 0;
volatile int request_started = 0;
@@ -1053,8 +1053,13 @@ int main(int argc, char *argv[])
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 */
@@ -1073,7 +1078,7 @@ int main(int argc, char *argv[])
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 = file_handle.filename;
+ SG(request_info)..path_translated = translated_path? translated_path : file_handle.filename;
argv[php_optind-1] = file_handle.filename;
SG(request_info).argv=argv+php_optind-1;
diff --git a/sapi/cli/tests/bug61546.phpt b/sapi/cli/tests/bug61546.phpt
new file mode 100644
index 0000000..2cd690f
--- /dev/null
+++ b/sapi/cli/tests/bug61546.phpt
@@ -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)