]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
We shouldn't be assigning the output of strtol to an unsigned short. So,
authorJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 18 Nov 2002 19:24:23 +0000 (19:24 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 18 Nov 2002 19:24:23 +0000 (19:24 +0000)
we'll change port to be a long and then do the correct range checking and
downcasting.

Suggested by: Roy Fielding

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@97564 13f79535-47bb-0310-9956-ffa450edef68

src/main/http_core.c

index cbd523b12aff480d56de11f24f5519428ef796ad..1e2a9e75e3b52cd66df44f122499c49416a8f1dd 100644 (file)
@@ -2597,7 +2597,7 @@ static const char *set_listener(cmd_parms *cmd, void *dummy, char *ips)
 {
     listen_rec *new;
     char *ports, *endptr;
-    unsigned short port;
+    long port;
     
     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
     if (err != NULL) {
@@ -2627,10 +2627,10 @@ static const char *set_listener(cmd_parms *cmd, void *dummy, char *ips)
        new->local_addr.sin_addr.s_addr = ap_get_virthost_addr(ips, NULL);
     }
     port = ap_strtol(ports, &endptr, 10);
-    if (errno || (endptr && *endptr) || !port) {
-       return "Missing or non-numeric port";
+    if (errno || (endptr && *endptr) || port < 1 || port > 65535) {
+       return "Missing, invalid, or non-numeric port";
     }
-    new->local_addr.sin_port = htons(port);
+    new->local_addr.sin_port = htons((unsigned short)port);
     new->fd = -1;
     new->used = 0;
     new->next = ap_listeners;