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).
This commit is contained in:
nil0x42 2014-07-11 19:48:03 +02:00 committed by Stanislav Malyshev
parent f75da60b18
commit a87300241f

View File

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