From 74cf8816030d55ce7c782fe34c28f40292fa8885 Mon Sep 17 00:00:00 2001 From: Justin Erenkrantz Date: Sun, 17 Nov 2002 22:29:14 +0000 Subject: [PATCH] If Listen directive is not a port, but just an IP, emit an error condition as this case is ambiguous. ('Listen 127.0.0.1' doesn't make any sense.) (Rich came up with the problem. Cliff came up with the error text. Justin did the ap_strtol call.) Reviewed by: Cliff Woolley, Rich Bowen git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@97553 13f79535-47bb-0310-9956-ffa450edef68 --- src/CHANGES | 5 +++++ src/main/http_core.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/CHANGES b/src/CHANGES index 144f3076b16..1d451ed3568 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,4 +1,9 @@ Changes with Apache 1.3.28 + + *) If Listen directive is not a port, but just an IP, emit an + error condition as this case is ambiguous. + [Rich Bowen, Justin Erenkrantz, Cliff Woolley] + *) Update timeout algorithm in free_proc_chain. If a subprocess did not exit immediately, the thread would sleep for 3 seconds before checking the subprocess exit status again. In a very diff --git a/src/main/http_core.c b/src/main/http_core.c index 3794f53f919..cbd523b12af 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -2596,7 +2596,7 @@ static const char *set_acceptfilter(cmd_parms *cmd, void *dummy, int flag) static const char *set_listener(cmd_parms *cmd, void *dummy, char *ips) { listen_rec *new; - char *ports; + char *ports, *endptr; unsigned short port; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); @@ -2626,9 +2626,9 @@ static const char *set_listener(cmd_parms *cmd, void *dummy, char *ips) else { new->local_addr.sin_addr.s_addr = ap_get_virthost_addr(ips, NULL); } - port = atoi(ports); - if (!port) { - return "Port must be numeric"; + port = ap_strtol(ports, &endptr, 10); + if (errno || (endptr && *endptr) || !port) { + return "Missing or non-numeric port"; } new->local_addr.sin_port = htons(port); new->fd = -1; -- 2.47.2