From 617fa490e5c07056788f77f5150ff8c0847c9941 Mon Sep 17 00:00:00 2001
From: Michal Karm Babacek <karm@redhat.com>
Date: Mon, 2 Mar 2015 15:09:22 +0100
Subject: [PATCH] MODCLUSTER-453 - appraoches the problem on MCMP message
 processing. Strings are stored escaped.

---
 native/mod_manager/mod_manager.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/native/mod_manager/mod_manager.c b/native/mod_manager/mod_manager.c
index ce027e8..cefdf28 100644
--- a/native/mod_manager/mod_manager.c
+++ b/native/mod_manager/mod_manager.c
@@ -26,6 +26,7 @@
  */
 
 #include "apr_strings.h"
+#include "apr_escape.h"
 #include "apr_lib.h"
 #include "apr_uuid.h"
 
@@ -843,8 +844,8 @@ static char * process_config(request_rec *r, char **ptr, int *errtype)
                 *errtype = TYPESYNTAX;
                 return SBALBIG;
             }
-            strcpy(nodeinfo.mess.balancer, ptr[i+1]);
-            strcpy(balancerinfo.balancer, ptr[i+1]);
+            strcpy(nodeinfo.mess.balancer, apr_pescape_entity(r->pool, ptr[i+1], 0));
+            strcpy(balancerinfo.balancer, nodeinfo.mess.balancer);
         }
         if (strcasecmp(ptr[i], "StickySession") == 0) {
             if (strcasecmp(ptr[i+1], "no") == 0)
@@ -855,14 +856,14 @@ static char * process_config(request_rec *r, char **ptr, int *errtype)
                 *errtype = TYPESYNTAX;
                 return SBAFBIG;
             }
-            strcpy(balancerinfo.StickySessionCookie, ptr[i+1]);
+            strcpy(balancerinfo.StickySessionCookie, apr_pescape_entity(r->pool, ptr[i+1], 0));
         }
         if (strcasecmp(ptr[i], "StickySessionPath") == 0) {
             if (strlen(ptr[i+1])>=sizeof(balancerinfo.StickySessionPath)) {
                 *errtype = TYPESYNTAX;
                 return SBAFBIG;
             }
-            strcpy(balancerinfo.StickySessionPath, ptr[i+1]);
+            strcpy(balancerinfo.StickySessionPath, apr_pescape_entity(r->pool, ptr[i+1], 0));
         }
         if (strcasecmp(ptr[i], "StickySessionRemove") == 0) {
             if (strcasecmp(ptr[i+1], "yes") == 0)
@@ -886,7 +887,7 @@ static char * process_config(request_rec *r, char **ptr, int *errtype)
                 *errtype = TYPESYNTAX;
                 return SROUBIG;
             }
-            strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+            strcpy(nodeinfo.mess.JVMRoute, apr_pescape_entity(r->pool, ptr[i+1], 0));
         }
         /* We renamed it LBGroup */
         if (strcasecmp(ptr[i], "Domain") == 0) {
@@ -972,10 +973,10 @@ static char * process_config(request_rec *r, char **ptr, int *errtype)
                phost->next = apr_palloc(r->pool, sizeof(struct cluster_host));
                phost = phost->next;
                phost->next = NULL;
-               phost->host = ptr[i+1];
+               phost->host = apr_pescape_entity(r->pool, ptr[i+1], 0);
                phost->context = NULL;
             } else {
-               phost->host = ptr[i+1];
+               phost->host = apr_pescape_entity(r->pool, ptr[i+1], 0);
             }
         }
         if (strcasecmp(ptr[i], "Context") == 0) {
@@ -983,7 +984,7 @@ static char * process_config(request_rec *r, char **ptr, int *errtype)
                 *errtype = TYPESYNTAX;
                 return SCONBAD;
             }
-            phost->context = ptr[i+1];
+            phost->context = apr_pescape_entity(r->pool, ptr[i+1], 0);
         }
         i++;
         i++;
@@ -1584,7 +1585,7 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
                 *errtype = TYPESYNTAX;
                 return SROUBIG;
             }
-            strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+            strcpy(nodeinfo.mess.JVMRoute, apr_pescape_entity(r->pool, ptr[i+1], 0));
             nodeinfo.mess.id = 0;
         }
         if (strcasecmp(ptr[i], "Alias") == 0) {
@@ -1592,14 +1593,14 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
                 *errtype = TYPESYNTAX;
                 return SMULALB;
             }
-            vhost->host = ptr[i+1];
+            vhost->host = apr_pescape_entity(r->pool, ptr[i+1], 0);
         }
         if (strcasecmp(ptr[i], "Context") == 0) {
             if (vhost->context) {
                 *errtype = TYPESYNTAX;
                 return SMULCTB;
             }
-            vhost->context = ptr[i+1];
+            vhost->context = apr_pescape_entity(r->pool, ptr[i+1], 0);
         }
         i++;
         i++;
@@ -1962,7 +1963,7 @@ static char * process_status(request_rec *r, char **ptr, int *errtype)
                 *errtype = TYPESYNTAX;
                 return SROUBIG;
             }
-            strcpy(nodeinfo.mess.JVMRoute, ptr[i+1]);
+            strcpy(nodeinfo.mess.JVMRoute, apr_pescape_entity(r->pool, ptr[i+1], 0));
             nodeinfo.mess.id = 0;
         }
         else if (strcasecmp(ptr[i], "Load") == 0) {
-- 
1.9.3

