]> granicus.if.org Git - apache/commitdiff
No more magic numbers.
authorJim Jagielski <jim@apache.org>
Wed, 16 Oct 2013 12:21:49 +0000 (12:21 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 16 Oct 2013 12:21:49 +0000 (12:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1532746 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy.c

index c55439283f9427fa8e4fbfce8bcfff4eca7451b3..f0dfbd4a5fedd9a2a9c9ad82a620ee0e5ecf7b39 100644 (file)
@@ -177,15 +177,17 @@ static const char *set_worker_param(apr_pool_t *p,
     else if (!strcasecmp(key, "route")) {
         /* Worker route.
          */
-        if (strlen(val) >= PROXY_WORKER_MAX_ROUTE_SIZE)
-            return "Route length must be < 64 characters";
+        if (strlen(val) >= sizeof(worker->s->route))
+            return apr_psprintf(p, "Route length must be < %d characters",
+                    (int)sizeof(worker->s->route));
         PROXY_STRNCPY(worker->s->route, val);
     }
     else if (!strcasecmp(key, "redirect")) {
         /* Worker redirection route.
          */
-        if (strlen(val) >= PROXY_WORKER_MAX_ROUTE_SIZE)
-            return "Redirect length must be < 64 characters";
+        if (strlen(val) >= sizeof(worker->s->redirect))
+            return apr_psprintf(p, "Redirect length must be < %d characters",
+                    (int)sizeof(worker->s->redirect));
         PROXY_STRNCPY(worker->s->redirect, val);
     }
     else if (!strcasecmp(key, "status")) {
@@ -256,8 +258,9 @@ static const char *set_worker_param(apr_pool_t *p,
         worker->s->conn_timeout_set = 1;
     }
     else if (!strcasecmp(key, "flusher")) {
-        if (strlen(val) >= PROXY_WORKER_MAX_SCHEME_SIZE)
-            return "flusher name length must be < 16 characters";
+        if (strlen(val) >= sizeof(worker->s->flusher))
+            apr_psprintf(p, "flusher name length must be < %d characters",
+                    (int)sizeof(worker->s->flusher));
         PROXY_STRNCPY(worker->s->flusher, val);
     }
     else {
@@ -280,8 +283,9 @@ static const char *set_balancer_param(proxy_server_conf *conf,
          * Set to something like JSESSIONID or
          * PHPSESSIONID, etc..,
          */
-        if (strlen(val) > (PROXY_BALANCER_MAX_STICKY_SIZE-1))
-            return "stickysession length must be < 64 characters";
+        if (strlen(val) >= sizeof(balancer->s->sticky_path))
+            apr_psprintf(p, "stickysession length must be < %d characters",
+                    (int)sizeof(balancer->s->sticky_path));
         PROXY_STRNCPY(balancer->s->sticky_path, val);
         PROXY_STRNCPY(balancer->s->sticky, val);