From: Aaron Bannert Date: Wed, 20 Nov 2002 22:38:26 +0000 (+0000) Subject: Clear errno before calling strtol, and add in some comments. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02c336664fccb0326c3e82e89bc3fae65bc6098f;p=thirdparty%2Fapache%2Fhttpd.git Clear errno before calling strtol, and add in some comments. Obtained from: Philippe M. Chiasson , Geoffrey Young 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 --- diff --git a/src/main/http_core.c b/src/main/http_core.c index 1e2a9e75e3b..6135fc8f3a8 100644 --- a/src/main/http_core.c +++ b/src/main/http_core.c @@ -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);