]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Migrate from strtol to ap_strtol, and use its known capability
authorJim Jagielski <jim@apache.org>
Tue, 18 Jun 2002 01:00:00 +0000 (01:00 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 18 Jun 2002 01:00:00 +0000 (01:00 +0000)
PR:
Obtained from:
Submitted by:
Reviewed by:

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

src/main/http_core.c
src/main/http_protocol.c
src/main/util.c
src/main/util_uri.c
src/modules/experimental/mod_auth_digest.c
src/modules/proxy/mod_proxy.c
src/modules/proxy/proxy_http.c
src/modules/proxy/proxy_util.c
src/modules/standard/mod_mime_magic.c
src/modules/test/mod_rndchunk.c
src/os/win32/mod_isapi.c

index b0339d8eb10edc7d34f6d5b8740cb0634f8d5dc1..f8090a581cfa3f37c3f433ad1db61d5c8e03877e 100644 (file)
@@ -2891,7 +2891,7 @@ static const char *set_limit_req_body(cmd_parms *cmd, core_dir_config *conf,
      *      Instead we have an idiotic define in httpd.h that prevents
      *      it from being used even when it is available. Sheesh.
      */
-    conf->limit_req_body = (unsigned long)strtol(arg, (char **)NULL, 10);
+    conf->limit_req_body = (unsigned long)ap_strtol(arg, (char **)NULL, 10);
     return NULL;
 }
 
index c234cd03b7c2277cf6e42afe26fb3b23cedef94a..b96a55e45b062df97277646e131323aa5d9b8b7f 100644 (file)
@@ -171,7 +171,7 @@ static enum byterange_token
     }
 
     if (ap_isdigit(*r->range))
-       *start = strtol(r->range, (char **)&r->range, 10);
+       *start = ap_strtol(r->range, (char **)&r->range, 10);
     else
        *start = -1;
 
@@ -186,7 +186,7 @@ static enum byterange_token
         ++r->range;
 
     if (ap_isdigit(*r->range))
-       *end = strtol(r->range, (char **)&r->range, 10);
+       *end = ap_strtol(r->range, (char **)&r->range, 10);
     else
        *end = -1;
 
@@ -1984,20 +1984,23 @@ API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy)
     }
     else if (lenp) {
         const char *pos = lenp;
+        int conversion_error = 0;
 
         while (ap_isdigit(*pos) || ap_isspace(*pos))
             ++pos;
-        if (*pos != '\0') {
-            ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
-                        "Invalid Content-Length %s", lenp);
-            return HTTP_BAD_REQUEST;
+
+        if (*pos == '\0') {
+            char *endstr;
+            errno = 0;
+            r->remaining = ap_strtol(lenp, &endstr, 10);
+            if (errno || (endstr && *endstr)) {
+                conversion_error = 1;
+            }
         }
 
-        r->remaining = atol(lenp);
-        if (r->remaining < 0) {
+        if (*pos != '\0' || conversion_error) {
             ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
-              "Request content-length of %s maps to negative number %ld",
-              lenp, r->remaining);
+                        "Invalid Content-Length");
             return HTTP_BAD_REQUEST;
         }
     }
index 4fe57f3566e7518382c1c8fe8b043365444da2fa..7a2d502a5aaf8093a1e9cbcaa7b9e5aa50c4015b 100644 (file)
@@ -1569,7 +1569,7 @@ static char x2c(const char *what)
     xstr[2]=what[0];
     xstr[3]=what[1];
     xstr[4]='\0';
-    digit = os_toebcdic[0xFF & strtol(xstr, NULL, 16)];
+    digit = os_toebcdic[0xFF & ap_strtol(xstr, NULL, 16)];
 #endif /*CHARSET_EBCDIC*/
     return (digit);
 }
index e61b7ba52baca8f8fc08d5eef3277f9e8843e65a..802790aa8294233e45989c7ee2a85ca6cb090a97 100644 (file)
@@ -428,7 +428,7 @@ API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri,
         ++s;
         uptr->port_str = ap_pstrndup(p, s, uri - s);
         if (uri != s) {
-            port = strtol(uptr->port_str, &endstr, 10);
+            port = ap_strtol(uptr->port_str, &endstr, 10);
             uptr->port = port;
             if (*endstr == '\0') {
                 goto deal_with_path;
@@ -483,7 +483,7 @@ API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo,
     ++s;
     uptr->port_str = ap_pstrdup(p, s);
     if (*s != '\0') {
-        uptr->port = (unsigned short)strtol(uptr->port_str, &endstr, 10);
+        uptr->port = (unsigned short)ap_strtol(uptr->port_str, &endstr, 10);
         if (*endstr == '\0') {
             return HTTP_OK;
         }
index cb8cd3ee836c961f11abdd96f05ebef9b92ebf10..5d4ae6f047ac8e8df311c17e92764259caff50b5 100644 (file)
@@ -573,7 +573,7 @@ static const char *set_nonce_lifetime(cmd_parms *cmd, void *config,
     char *endptr;
     long  lifetime;
 
-    lifetime = strtol(t, &endptr, 10);
+    lifetime = ap_strtol(t, &endptr, 10);
     if (endptr < (t+strlen(t)) && !ap_isspace(*endptr))
        return ap_pstrcat(cmd->pool, "Invalid time in AuthDigestNonceLifetime: ", t, NULL);
 
@@ -933,7 +933,7 @@ static int get_digest_rec(request_rec *r, digest_header_rec *resp)
     }
 
     if (resp->opaque)
-       resp->opaque_num = (unsigned long) strtol(resp->opaque, NULL, 16);
+       resp->opaque_num = (unsigned long) ap_strtol(resp->opaque, NULL, 16);
 
     resp->auth_hdr_sts = VALID;
     return OK;
@@ -1375,7 +1375,7 @@ static int check_nc(const request_rec *r, const digest_header_rec *resp,
     if (!conf->check_nc || !client_mm)
        return OK;
 
-    nc = strtol(snc, &endptr, 16);
+    nc = ap_strtol(snc, &endptr, 16);
     if (endptr < (snc+strlen(snc)) && !ap_isspace(*endptr)) {
        ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
                      "Digest: invalid nc %s received - not a number", snc);
index 7485901a16f5e0084044744f3003a3c63005561e..6cca3c07841a4872c177be22a481e0f1fae35cd8 100644 (file)
@@ -305,7 +305,7 @@ static int proxy_handler(request_rec *r)
 
     if (r->method_number == M_TRACE &&
         (maxfwd_str = ap_table_get(r->headers_in, "Max-Forwards")) != NULL) {
-        long maxfwd = strtol(maxfwd_str, NULL, 10);
+        long maxfwd = ap_strtol(maxfwd_str, NULL, 10);
         if (maxfwd < 1) {
             int access_status;
             r->proxyreq = NOT_PROXY;
index 6a12ea206420426f185ddeda3ec13346bf6f6000..6a9a4443fb800f8e7f202d8d0dc6217b578a83db 100644 (file)
@@ -517,7 +517,7 @@ int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
 
         content_length = ap_table_get(resp_hdrs, "Content-Length");
         if (content_length != NULL) {
-            c->len = strtol(content_length, NULL, 10);
+            c->len = ap_strtol(content_length, NULL, 10);
         }
 
         /* Now add out bound headers set by other modules */
index 56bdfd6a37454f2c3ff2e4f2883fb96145ad63ce..d350412e9383b36350b29bae160bcdabb8b33e21 100644 (file)
@@ -1072,7 +1072,7 @@ int ap_proxy_is_ipaddr(struct dirconn_entry *This, pool *p)
         if (!ap_isdigit(*addr))
             return 0;           /* no digit at start of quad */
 
-        ip_addr[quads] = strtol(addr, &tmp, 0);
+        ip_addr[quads] = ap_strtol(addr, &tmp, 0);
 
         if (tmp == addr)        /* expected a digit, found something else */
             return 0;
@@ -1096,7 +1096,7 @@ int ap_proxy_is_ipaddr(struct dirconn_entry *This, pool *p)
 
         ++addr;
 
-        bits = strtol(addr, &tmp, 0);
+        bits = ap_strtol(addr, &tmp, 0);
 
         if (tmp == addr)        /* expected a digit, found something else */
             return 0;
index 77e1f1b8cc929e6e263109cd9f9d49c9dfa2e065..2ec733f77c44ab3c07df8790800d4f248f8bbcd0 100644 (file)
@@ -1110,7 +1110,7 @@ static int parse(server_rec *serv, pool *p, char *l, int lineno)
     }
 
     /* get offset, then skip over it */
-    m->offset = (int) strtol(l, &t, 0);
+    m->offset = (int) ap_strtol(l, &t, 0);
     if (l == t) {
        ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, serv,
                    MODNAME ": offset %s invalid", l);
@@ -1145,7 +1145,7 @@ static int parse(server_rec *serv, pool *p, char *l, int lineno)
        if (*l == '+' || *l == '-')
            l++;
        if (ap_isdigit((unsigned char) *l)) {
-           m->in.offset = strtol(l, &t, 0);
+           m->in.offset = ap_strtol(l, &t, 0);
            if (*s == '-')
                m->in.offset = -m->in.offset;
        }
@@ -1233,7 +1233,7 @@ static int parse(server_rec *serv, pool *p, char *l, int lineno)
     /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
     if (*l == '&') {
        ++l;
-       m->mask = signextend(serv, m, strtol(l, &l, 0));
+       m->mask = signextend(serv, m, ap_strtol(l, &l, 0));
     }
     else
        m->mask = ~0L;
@@ -1311,7 +1311,7 @@ static int getvalue(server_rec *s, struct magic *m, char **p)
        m->vallen = slen;
     }
     else if (m->reln != 'x')
-       m->value.l = signextend(s, m, strtol(*p, p, 0));
+       m->value.l = signextend(s, m, ap_strtol(*p, p, 0));
     return 0;
 }
 
index 0b9061c4c48133155a3b149c9ed609f17e2c8a26..5ce5385fd4355a6c97559435552175a89942a159 100644 (file)
@@ -128,12 +128,12 @@ error:
        ap_kill_timeout(r);
        return 0;
     }
-    seed = strtol(args, &endptr, 0);
+    seed = ap_strtol(args, &endptr, 0);
     if (!endptr || *endptr != ',') {
        goto error;
     }
     ++endptr;
-    count = strtol(endptr, &endptr, 0);
+    count = ap_strtol(endptr, &endptr, 0);
 
     srandom(seed);
     for (i = 0; i < count; ++i) {
index 0f502e275f985c0282307ba6d2d413c0d825b9b6..0065e92906534538c3f11fae55ef28833a47bffa 100644 (file)
@@ -825,7 +825,7 @@ static const char *isapi_cmd_readaheadbuffer(cmd_parms *cmd, void *config,
         return err;
     }
 
-    if (((val = strtol(arg, (char **) &err, 10)) <= 0) || *err)
+    if (((val = ap_strtol(arg, (char **) &err, 10)) <= 0) || *err)
         return "ISAPIReadAheadBuffer must be a legitimate value.";
     
     ReadAheadBuffer = val;