]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Clear errno before calling strtol, and add in some comments.
authorAaron Bannert <aaron@apache.org>
Wed, 20 Nov 2002 22:38:26 +0000 (22:38 +0000)
committerAaron Bannert <aaron@apache.org>
Wed, 20 Nov 2002 22:38:26 +0000 (22:38 +0000)
Obtained from:  Philippe M. Chiasson <gozer@cpan.org>,
                Geoffrey Young <geoff@modperlcookbook.org>
Submitted by: Aaron Bannert

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

src/main/http_core.c

index 1e2a9e75e3b52cd66df44f122499c49416a8f1dd..6135fc8f3a849d3a7ab33aa158c37047c6a3e6bd 100644 (file)
@@ -2626,8 +2626,12 @@ 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);
     }
+    errno = 0; /* clear errno before calling strtol */
     port = ap_strtol(ports, &endptr, 10);
-    if (errno || (endptr && *endptr) || port < 1 || port > 65535) {
+    if (errno /* some sort of error */
+       || (endptr && *endptr) /* make sure no trailing characters */
+       || port < 1 || port > 65535) /* underflow/overflow */
+    {
        return "Missing, invalid, or non-numeric port";
     }
     new->local_addr.sin_port = htons((unsigned short)port);