From 2534671f0be23b4bf93f0d726684895af77f39e0 Mon Sep 17 00:00:00 2001 From: nil0x42 Date: Fri, 11 Jul 2014 19:48:03 +0200 Subject: 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). --- sapi/cli/php_cli_server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sapi/cli/php_cli_server.c') diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 49680cede4..a0a9052f8a 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -2233,7 +2233,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') { @@ -2249,7 +2249,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; } } -- cgit v1.2.1