summaryrefslogtreecommitdiff
path: root/sapi/cli
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-01-12 18:18:45 +0100
committerNikita Popov <nikita.ppv@gmail.com>2018-01-12 18:18:45 +0100
commitb942648771a4638d4d043e2b2836f34c139cace3 (patch)
tree0645db8b5802aa7ceb6b5df0d1f3c4ce83573892 /sapi/cli
parent4121f2a1adc9ea486ed3a71409e1120ccedecc1b (diff)
parentf8c889760cbbe1fa30159b571ab85cf726ba81c5 (diff)
downloadphp-git-b942648771a4638d4d043e2b2836f34c139cace3.tar.gz
Merge branch 'PHP-7.2'
Diffstat (limited to 'sapi/cli')
-rw-r--r--sapi/cli/php_cli_server.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 72eb1c170d..6053ee9340 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2098,6 +2098,12 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server
{
int decline = 0;
zend_file_handle zfd;
+ char *old_cwd;
+
+ ALLOCA_FLAG(use_heap)
+ old_cwd = do_alloca(MAXPATHLEN, use_heap);
+ old_cwd[0] = '\0';
+ php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1));
zfd.type = ZEND_HANDLE_FILENAME;
zfd.filename = server->router;
@@ -2119,6 +2125,12 @@ static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server
}
} zend_end_try();
+ if (old_cwd[0] != '\0') {
+ php_ignore_value(VCWD_CHDIR(old_cwd));
+ }
+
+ free_alloca(old_cwd, use_heap);
+
return decline;
}
/* }}} */
@@ -2310,20 +2322,10 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
if (router) {
size_t router_len = strlen(router);
- if (!IS_ABSOLUTE_PATH(router, router_len)) {
- _router = pemalloc(server->document_root_len + router_len + 2, 1);
- if (!_router) {
- retval = FAILURE;
- goto out;
- }
- snprintf(_router,
- server->document_root_len + router_len + 2, "%s%c%s", server->document_root, DEFAULT_SLASH, router);
- } else {
- _router = pestrndup(router, router_len, 1);
- if (!_router) {
- retval = FAILURE;
- goto out;
- }
+ _router = pestrndup(router, router_len, 1);
+ if (!_router) {
+ retval = FAILURE;
+ goto out;
}
server->router = _router;
server->router_len = router_len;