com php-src: Fix php cli (-S option) inconsistent port parsing: sapi/cli/php_cli_server.c
| From: | Stanislav Malyshev | Date: | Mon, 01 Dec 2014 06:29:24 +0000 |
| Subject: | com php-src: Fix php cli (-S option) inconsistent port parsing: sapi/cli/php_cli_server.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83441@lists.php.net to get a copy of this message | ||
Commit: a87300241fc065c0020c7caf7a0e2e9b57405ad0
Author: nil0x42 <nil0x42@users.noreply.github.com> Fri, 11 Jul 2014 19:48:03 +0200
Committer: Stanislav Malyshev <stas@php.net> Sun, 30 Nov 2014 22:29:24 -0800
Parents: f75da60b18f12fb986179caf59523921e9f49bbc
Branches: PHP-5.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a87300241fc065c0020c7caf7a0e2e9b57405ad0
Log:
Fix php cli (-S option) inconsistent port parsing
Add port range verification of listening port with -S option for the php cli.
This fixes inconsistent listening port due to unverified cast from long to short
with htons(3).
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 6cefa2d..5e38fa5 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -2257,7 +2257,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const
c
*p++ = '\0';
if (*p == ':') {
port = strtol(p + 1, &p, 10);
- if (port <= 0) {
+ if (port <= 0 || port > 65535) {
p = NULL;
}
} else if (*p != '\0') {
@@ -2273,7 +2273,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const
c
if (p) {
*p++ = '\0';
port = strtol(p, &p, 10);
- if (port <= 0) {
+ if (port <= 0 || port > 65535) {
p = NULL;
}
}