com php-src: Fixed bug #73830 Directory does not exist.: sapi/cli/php_cli_server.c
| From: | Anatol Belski | Date: | Tue, 28 Nov 2017 11:41:49 +0000 |
| Subject: | com php-src: Fixed bug #73830 Directory does not exist.: sapi/cli/php_cli_server.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100408@lists.php.net to get a copy of this message | ||
Commit: 578049fdb6a69c7cd46ff62838384d1d9b1c88c4
Author: Anatol Belski <ab@php.net> Tue, 28 Nov 2017 12:41:49 +0100
Parents: ee9e32caca08262de878395f6aff3eed54fc5740
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=578049fdb6a69c7cd46ff62838384d1d9b1c88c4
Log:
Fixed bug #73830 Directory does not exist.
Bugs:
https://bugs.php.net/73830
Changed paths:
M sapi/cli/php_cli_server.c
Diff:
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 1f9e5ab..a9e08f1 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2552,6 +2552,10 @@ int do_cli_server(int argc, char **argv) /* {{{ */
const char *server_bind_address = NULL;
extern const opt_struct OPTIONS[];
const char *document_root = NULL;
+#ifdef PHP_WIN32
+ char document_root_tmp[MAXPATHLEN];
+ size_t k;
+#endif
const char *router = NULL;
char document_root_buf[MAXPATHLEN];
@@ -2561,7 +2565,23 @@ int do_cli_server(int argc, char **argv) /* {{{ */
server_bind_address = php_optarg;
break;
case 't':
+#ifndef PHP_WIN32
document_root = php_optarg;
+#else
+ k = strlen(php_optarg);
+ if (k + 1 > MAXPATHLEN) {
+ fprintf(stderr, "Document root path is too long.\n");
+ return 1;
+ }
+ memmove(document_root_tmp, php_optarg, k + 1);
+ /* Clean out any trailing garbage that might have been passed
+ from a batch script. */
+ do {
+ document_root_tmp[k] = '\0';
+ k--;
+ } while ('"' == document_root_tmp[k] || ' ' == document_root_tmp[k]);
+ document_root = document_root_tmp;
+#endif
break;
}
}