mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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:
parent
cb1a297bf4
commit
2a73d56ef9
1 changed files with 2 additions and 2 deletions
|
@ -2256,7 +2256,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
port = strtol(p + 1, &p, 10);
|
port = strtol(p + 1, &p, 10);
|
||||||
if (port <= 0) {
|
if (port <= 0 || port > 65535) {
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
} else if (*p != '\0') {
|
} else if (*p != '\0') {
|
||||||
|
@ -2272,7 +2272,7 @@ static int php_cli_server_ctor(php_cli_server *server, const char *addr, const c
|
||||||
if (p) {
|
if (p) {
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
port = strtol(p, &p, 10);
|
port = strtol(p, &p, 10);
|
||||||
if (port <= 0) {
|
if (port <= 0 || port > 65535) {
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue