]> granicus.if.org Git - apache/commitdiff
Merge r1681795, r1682988, r1682979, r1682819, r1682816 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 2 Jun 2015 13:40:41 +0000 (13:40 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 2 Jun 2015 13:40:41 +0000 (13:40 +0000)
initialize args to not print garbage mem during a RewriteRule parse error

Initialize args to not print garbage mem during a RewriteCond parse error (same as r1681795 for RewriteRule)

Improve style in examples.

Improve error message (related to PR57311 diagnostic)

Concat string at compile time in order to save a few cycles.

Submitted by: covener, jailletc36, jailletc36, jailletc36, jailletc36
Reviewed/backported by: jim

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

STATUS
modules/examples/mod_case_filter.c
modules/examples/mod_case_filter_in.c
modules/examples/mod_example_hooks.c
modules/examples/mod_example_ipc.c
modules/mappers/mod_rewrite.c
modules/proxy/mod_proxy_wstunnel.c
modules/proxy/proxy_util.c

diff --git a/STATUS b/STATUS
index 6bab9da7f1484b80ca8513f1e282fca0a967efeb..977f03ba04c93e3cb969a8227e7ef37e78617a63 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -105,21 +105,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   *) Easy patches - synch with trunk
-        - mod_rewrite: Initialize args to not print garbage mem during a RewriteCond parse error
-        - mod_rewrite: Initialize args to not print garbage mem during a RewriteRule parse error
-        - examples/mod_*: Improve style in examples.
-        - proxy_util: Improve error message
-        - mod_proxy_wstunnel: Concat string at compile time in orser to save a few cycles.
-     trunk patch:
-        http://svn.apache.org/r1681795
-        http://svn.apache.org/r1682988
-        http://svn.apache.org/r1682979
-        http://svn.apache.org/r1682819
-        http://svn.apache.org/r1682816
-     2.4.x patch: trunk patchs work
-     +1: jailletc36, ylavic, jim
-
 
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
index f0b84d2900f096c33ff6fbfc4ee8bde7a1fa4381..409f65bfa662ec15ad9ef23f3c15e195cd7566eb 100644 (file)
 
 #include <ctype.h>
 
-static const char s_szCaseFilterName[]="CaseFilter";
+static const char s_szCaseFilterName[] = "CaseFilter";
 module AP_MODULE_DECLARE_DATA case_filter_module;
 
 typedef struct
-    {
+{
     int bEnabled;
-    } CaseFilterConfig;
+} CaseFilterConfig;
 
-static void *CaseFilterCreateServerConfig(apr_pool_t *p,server_rec *s)
-    {
-    CaseFilterConfig *pConfig=apr_pcalloc(p,sizeof *pConfig);
+static void *CaseFilterCreateServerConfig(apr_pool_t *p, server_rec *s)
+{
+    CaseFilterConfig *pConfig = apr_pcalloc(p,sizeof *pConfig);
 
-    pConfig->bEnabled=0;
+    pConfig->bEnabled = 0;
 
     return pConfig;
-    }
+}
 
 static void CaseFilterInsertFilter(request_rec *r)
-    {
-    CaseFilterConfig *pConfig=ap_get_module_config(r->server->module_config,
-                                                   &case_filter_module);
+{
+    CaseFilterConfig *pConfig = ap_get_module_config(r->server->module_config,
+                                                     &case_filter_module);
 
-    if(!pConfig->bEnabled)
+    if (!pConfig->bEnabled)
         return;
 
-    ap_add_output_filter(s_szCaseFilterName,NULL,r,r->connection);
-    }
+    ap_add_output_filter(s_szCaseFilterName, NULL, r, r->connection);
+}
 
 static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
                                         apr_bucket_brigade *pbbIn)
-    {
+{
     request_rec *r = f->r;
     conn_rec *c = r->connection;
     apr_bucket *pbktIn;
     apr_bucket_brigade *pbbOut;
 
-    pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
+    pbbOut = apr_brigade_create(r->pool, c->bucket_alloc);
     for (pbktIn = APR_BRIGADE_FIRST(pbbIn);
          pbktIn != APR_BRIGADE_SENTINEL(pbbIn);
          pbktIn = APR_BUCKET_NEXT(pbktIn))
@@ -71,25 +71,25 @@ static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
         apr_size_t n;
         apr_bucket *pbktOut;
 
-        if(APR_BUCKET_IS_EOS(pbktIn))
-            {
-            apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
-            APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
+        if (APR_BUCKET_IS_EOS(pbktIn)) {
+            apr_bucket *pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
+            APR_BRIGADE_INSERT_TAIL(pbbOut, pbktEOS);
             continue;
-            }
+        }
 
         /* read */
-        apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
+        apr_bucket_read(pbktIn, &data, &len, APR_BLOCK_READ);
 
         /* write */
         buf = apr_bucket_alloc(len, c->bucket_alloc);
-        for(n=0 ; n < len ; ++n)
+        for (n=0 ; n < len ; ++n) {
             buf[n] = apr_toupper(data[n]);
+        }
 
         pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free,
                                          c->bucket_alloc);
-        APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
-        }
+        APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut);
+    }
 
     /* Q: is there any advantage to passing a brigade for each bucket?
      * A: obviously, it can cut down server resource consumption, if this
@@ -101,31 +101,31 @@ static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
      * don't let our caller pass the same buckets to us, twice;
      */
     apr_brigade_cleanup(pbbIn);
-    return ap_pass_brigade(f->next,pbbOut);
-    }
+    return ap_pass_brigade(f->next, pbbOut);
+}
 
 static const char *CaseFilterEnable(cmd_parms *cmd, void *dummy, int arg)
-    {
-    CaseFilterConfig *pConfig=ap_get_module_config(cmd->server->module_config,
-                                                   &case_filter_module);
-    pConfig->bEnabled=arg;
+{
+    CaseFilterConfig *pConfig = ap_get_module_config(cmd->server->module_config,
+                                                     &case_filter_module);
+    pConfig->bEnabled = arg;
 
     return NULL;
-    }
+}
 
 static const command_rec CaseFilterCmds[] =
-    {
+{
     AP_INIT_FLAG("CaseFilter", CaseFilterEnable, NULL, RSRC_CONF,
                  "Run a case filter on this host"),
     { NULL }
-    };
+};
 
 static void CaseFilterRegisterHooks(apr_pool_t *p)
-    {
-    ap_hook_insert_filter(CaseFilterInsertFilter,NULL,NULL,APR_HOOK_MIDDLE);
-    ap_register_output_filter(s_szCaseFilterName,CaseFilterOutFilter,NULL,
+{
+    ap_hook_insert_filter(CaseFilterInsertFilter, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_register_output_filter(s_szCaseFilterName, CaseFilterOutFilter, NULL,
                               AP_FTYPE_RESOURCE);
-    }
+}
 
 AP_DECLARE_MODULE(case_filter) =
 {
index 73af077afaae0a74a7da490e1a23c7bcf65632ee..7200765b3aa896e453fde862f92c0b992878e768 100644 (file)
@@ -53,12 +53,12 @@ static void *CaseFilterInCreateServerConfig(apr_pool_t *p, server_rec *s)
 
 static void CaseFilterInInsertFilter(request_rec *r)
 {
-    CaseFilterInConfig *pConfig=ap_get_module_config(r->server->module_config,
-                                                     &case_filter_in_module);
-    if(!pConfig->bEnabled)
+    CaseFilterInConfig *pConfig = ap_get_module_config(r->server->module_config,
+                                                       &case_filter_in_module);
+    if (!pConfig->bEnabled)
         return;
 
-    ap_add_input_filter(s_szCaseFilterName,NULL,r,r->connection);
+    ap_add_input_filter(s_szCaseFilterName, NULL, r, r->connection);
 }
 
 static apr_status_t CaseFilterInFilter(ap_filter_t *f,
@@ -84,7 +84,7 @@ static apr_status_t CaseFilterInFilter(ap_filter_t *f,
             return ret;
     }
 
-    while(!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) {
+    while (!APR_BRIGADE_EMPTY(pCtx->pbbTmp)) {
         apr_bucket *pbktIn = APR_BRIGADE_FIRST(pCtx->pbbTmp);
         apr_bucket *pbktOut;
         const char *data;
@@ -106,12 +106,13 @@ static apr_status_t CaseFilterInFilter(ap_filter_t *f,
         }
 
         ret=apr_bucket_read(pbktIn, &data, &len, eBlock);
-        if(ret != APR_SUCCESS)
+        if (ret != APR_SUCCESS)
             return ret;
 
         buf = ap_malloc(len);
-        for(n=0 ; n < len ; ++n)
+        for (n=0 ; n < len ; ++n) {
             buf[n] = apr_toupper(data[n]);
+        }
 
         pbktOut = apr_bucket_heap_create(buf, len, 0, c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut);
@@ -121,7 +122,6 @@ static apr_status_t CaseFilterInFilter(ap_filter_t *f,
     return APR_SUCCESS;
 }
 
-
 static const char *CaseFilterInEnable(cmd_parms *cmd, void *dummy, int arg)
 {
     CaseFilterInConfig *pConfig
index 1130f7eb39679b96b941795df581aa9a08caafdb..4db0865cccb7028ee3cd4055cc7cb76c9dbc4ecf 100644 (file)
@@ -329,7 +329,8 @@ static void example_log_each(apr_pool_t *p, server_rec *s, const char *note)
 {
     if (s != NULL) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_example_hooks: %s", note);
-    } else {
+    }
+    else {
         apr_file_t *out = NULL;
         apr_file_open_stderr(&out, p);
         apr_file_printf(out, "mod_example_hooks traced in non-loggable "
@@ -741,7 +742,6 @@ static int x_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
      * Log the call and exit.
      */
     trace_startup(ptemp, NULL, NULL, "x_pre_config()");
-
     return OK;
 }
 
@@ -1049,7 +1049,8 @@ static int x_handler(request_rec *r)
                                     r->connection->pool);
     if ((status == APR_SUCCESS) && conn_data) {
         ap_rprintf(r, "  <OL>\n%s  </OL>\n", (char *) conn_data);
-    } else {
+    }
+    else {
         ap_rputs("  <P>No connection-specific callback information was "
                  "retrieved.</P>\n", r);
     }
@@ -1135,7 +1136,6 @@ static int x_pre_connection(conn_rec *c, void *csd)
 static int x_process_connection(conn_rec *c)
 {
     trace_connection(c, "x_process_connection()");
-
     return DECLINED;
 }
 
@@ -1181,7 +1181,6 @@ static int x_post_read_request(request_rec *r)
  */
 static int x_translate_name(request_rec *r)
 {
-
     /*
      * We don't actually *do* anything here, except note the fact that we were
      * called.
index b8ba569c067adca623700b3759fcd5448244f74b..a7cdb34d1bbc30baddc02989cd5f15f7d05dcde0 100644 (file)
@@ -91,7 +91,8 @@ typedef struct exipc_data {
  * on restarts. It assures that the new children will not talk to a stale
  * shared memory segment.
  */
-static apr_status_t shm_cleanup_wrapper(void *unused) {
+static apr_status_t shm_cleanup_wrapper(void *unused)
+{
     if (exipc_shm)
         return apr_shm_destroy(exipc_shm);
     return OK;
@@ -248,10 +249,12 @@ static int exipc_handler(request_rec *r)
         rs = apr_global_mutex_trylock(exipc_mutex);
         if (APR_STATUS_IS_EBUSY(rs)) {
             apr_sleep(CAMPOUT);
-        } else if (APR_SUCCESS == rs) {
+        }
+        else if (APR_SUCCESS == rs) {
             gotlock = 1;
             break; /* Get out of the loop */
-        } else if (APR_STATUS_IS_ENOTIMPL(rs)) {
+        }
+        else if (APR_STATUS_IS_ENOTIMPL(rs)) {
             /* If it's not implemented, just hang in the mutex. */
             startcamp = apr_time_now();
             rs = apr_global_mutex_lock(exipc_mutex);
@@ -259,21 +262,23 @@ static int exipc_handler(request_rec *r)
             if (APR_SUCCESS == rs) {
                 gotlock = 1;
                 break; /* Out of the loop */
-            } else {
+            }
+            else {
                 /* Some error, log and bail */
                 ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server,
                              "Child %ld failed to acquire lock",
                              (long int)getpid());
                 break; /* Out of the loop without having the lock */
             }
-        } else {
+        }
+        else {
             /* Some other error, log and bail */
             ap_log_error(APLOG_MARK, APLOG_ERR, rs, r->server,
                          "Child %ld failed to try and acquire lock",
                          (long int)getpid());
             break; /* Out of the loop without having the lock */
-
         }
+
         /*
          * The only way to get to this point is if the trylock worked
          * and returned BUSY. So, bump the time and try again
@@ -307,7 +312,8 @@ static int exipc_handler(request_rec *r)
             ap_rprintf(r, "<tr><td>Counter:</td><td>%u</td></tr>\n",
                        (unsigned int)base->counter);
             ap_rputs("</table>\n", r);
-        } else {
+        }
+        else {
             /*
              * Send a page saying that we couldn't get the lock. Don't say
              * what the counter is, because without the lock the value could
@@ -348,4 +354,3 @@ AP_DECLARE_MODULE(example_ipc) = {
     NULL,                  /* table of config file commands       */
     exipc_register_hooks   /* register hooks                      */
 };
-
index 92c3cd7fc05bf0138e55abd9faada9affacdb5ed..f1ed708bff325de91be9323bf82d0c03e2d4b028 100644 (file)
@@ -3238,9 +3238,7 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
     rewrite_server_conf *sconf;
     rewritecond_entry *newcond;
     ap_regex_t *regexp;
-    char *a1;
-    char *a2;
-    char *a3;
+    char *a1 = NULL, *a2 = NULL, *a3 = NULL;
     const char *err;
 
     sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
@@ -3657,9 +3655,7 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
     rewrite_server_conf *sconf;
     rewriterule_entry *newrule;
     ap_regex_t *regexp;
-    char *a1;
-    char *a2;
-    char *a3;
+    char *a1 = NULL, *a2 = NULL, *a3 = NULL;
     const char *err;
 
     sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
index 7c283b8e02250025bae21d225abe2fc1461877f2..d75d00432d49a98b5a0f32c7e4e284401e1ee495 100644 (file)
@@ -183,7 +183,7 @@ static int proxy_wstunnel_request(apr_pool_t *p, request_rec *r,
         return rv;
     }
 
-    buf = apr_pstrcat(p, "Upgrade: WebSocket", CRLF, "Connection: Upgrade", CRLF, CRLF, NULL);
+    buf = apr_pstrdup(p, "Upgrade: WebSocket" CRLF "Connection: Upgrade" CRLF CRLF);
     ap_xlate_proto_to_ascii(buf, strlen(buf));
     e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
     APR_BRIGADE_INSERT_TAIL(header_brigade, e);
index 0b8b30c94d7bcf14e2c34fee4b55be666d8eca29..b35278a746fc2b4e85e12343568e75c01aa5dcf2 100644 (file)
@@ -1159,7 +1159,7 @@ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
 
     c = strchr(uri, ':');
     if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0')
-        return "Bad syntax for a balancer name";
+        return apr_psprintf(p, "Bad syntax for a balancer name (%s)", uri);
     /* remove path from uri */
     if ((q = strchr(c + 3, '/')))
         *q = '\0';