You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/10/16 14:21:49 UTC

svn commit: r1532746 - /httpd/httpd/trunk/modules/proxy/mod_proxy.c

Author: jim
Date: Wed Oct 16 12:21:49 2013
New Revision: 1532746

URL: http://svn.apache.org/r1532746
Log:
No more magic numbers.

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1532746&r1=1532745&r2=1532746&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Wed Oct 16 12:21:49 2013
@@ -177,15 +177,17 @@ static const char *set_worker_param(apr_
     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_
         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(pr
          * 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);