]> granicus.if.org Git - apache/commitdiff
Various code cleanup
authorStefan Fritsch <sf@apache.org>
Wed, 22 Jun 2011 20:45:34 +0000 (20:45 +0000)
committerStefan Fritsch <sf@apache.org>
Wed, 22 Jun 2011 20:45:34 +0000 (20:45 +0000)
PR: 51398
Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1138627 13f79535-47bb-0310-9956-ffa450edef68

modules/aaa/mod_authnz_ldap.c
modules/cluster/mod_heartmonitor.c
modules/dav/fs/repos.c
modules/dav/main/mod_dav.c
modules/mappers/mod_rewrite.c
modules/proxy/mod_serf.c
modules/proxy/proxy_util.c
server/util.c
server/vhost.c

index a3cd161d63d9d2143b791ae9ecc523da2f32686d..95bec065e43aa0de5fb10a11e2473d8738ef626f 100644 (file)
@@ -1378,8 +1378,8 @@ static const char *mod_auth_ldap_parse_url(cmd_parms *cmd,
              * Get rid of the surrounding parens; later on when generating the
              * filter, they'll be put back.
              */
-            sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter+1);
-            sec->filter[strlen(sec->filter)-1] = '\0';
+            sec->filter = apr_pstrmemdup(cmd->pool, urld->lud_filter+1,
+                                                    strlen(urld->lud_filter)-2);
         }
         else {
             sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter);
index 822a2cd33ff4f07d4ee1028c4eef42c0915a3b53..f2240c66f22fc3fc78a8a725f72548d23d12e1bf 100644 (file)
@@ -770,7 +770,7 @@ static int hm_handler(request_rec *r)
 
     ap_set_content_type(r, "text/plain");
     ap_set_content_length(r, 2);
-    ap_rprintf(r, "OK");
+    ap_rputs("OK", r);
     ap_rflush(r);
 
     return OK;
index 58cd7059a96828c82fc293ba510c84dc02b930a8..c63205ebd4543ee1f406f6e39f6d629531197547 100644 (file)
@@ -719,8 +719,7 @@ static dav_error * dav_fs_get_resource(
     /* make sure the URI does not have a trailing "/" */
     len = strlen(r->uri);
     if (len > 1 && r->uri[len - 1] == '/') {
-        s = apr_pstrdup(r->pool, r->uri);
-        s[len - 1] = '\0';
+        s = apr_pstrmemdup(r->pool, r->uri, len-1);
         resource->uri = s;
     }
     else {
index d021b91e16e220e1d87e41b29f3f0bb461e8115d..c246c3caaef0ba619f7cb792c551fe5933258ea7 100644 (file)
@@ -160,8 +160,8 @@ static void *dav_create_dir_config(apr_pool_t *p, char *dir)
         char *d;
         apr_size_t l;
 
-        d = apr_pstrdup(p, dir);
-        l = strlen(d);
+        l = strlen(dir);
+        d = apr_pstrmemdup(p, dir, l);
         if (l > 1 && d[l - 1] == '/')
             d[l - 1] = '\0';
         conf->dir = d;
index f7f02b582da58056f03cf975a2921979efcae938..cd14687afbe354d1bbfa55cc2cc8bfb6d246ab30 100644 (file)
@@ -1759,7 +1759,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
 
     /* fast exit */
     if (varlen < 4) {
-        return apr_pstrdup(r->pool, "");
+        return "";
     }
 
     result = NULL;
@@ -2211,7 +2211,7 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry)
 
     /* fast exit */
     if (inputlen == span) {
-        return apr_pstrdup(pool, input);
+        return apr_pstrmemdup(pool, input, inputlen);
     }
 
     /* well, actually something to do */
index c0fec739b7a458562786618b18af621336904c99..cc00eceed5a47300d0448ec42cce406cfeac4e6c 100644 (file)
@@ -634,8 +634,7 @@ static int serf_handler(request_rec *r)
 
 static int is_true(const char *w)
 {
-    if (strcasecmp(w, "on") == 0 || 
-        strcasecmp(w, "1") == 0 ||
+    if (strcasecmp(w, "on") == 0 || strcmp(w, "1") == 0 ||
         strcasecmp(w, "true") == 0)
     {
         return 1;
@@ -678,8 +677,7 @@ static const char *add_pass(cmd_parms *cmd, void *vconf,
         const char *x = ap_strchr_c(p, '=');
         
         if (x) {
-            char *key = apr_pstrndup(cmd->pool, p, x-p);
-            if (strcmp(key, "preservehost") == 0) {
+            if (strncmp(p, "preservehost", x-p) == 0) {
                 conf->preservehost = is_true(x+1);
             }
         }
index 27d774cbe80ac8a22fe07972935902f7f16d8654..d78b5f6a91079ca5d7e791ddbaa96f0c1b9ef518 100644 (file)
@@ -1682,8 +1682,8 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
         return NULL;
     }
 
-    url_copy = apr_pstrdup(p, url);
     url_length = strlen(url);
+    url_copy = apr_pstrmemdup(p, url, url_length);
 
     /*
      * We need to find the start of the path and
index 51e8becb93b17b6684f513a4c2747be152e26012..8e1a6209ae57578ac78e0cd7b940bf45bef910ea 100644 (file)
@@ -670,8 +670,9 @@ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *atrans, const char **line,
     char *res;
 
     if (!pos) {
-        res = apr_pstrdup(atrans, *line);
-        *line += strlen(*line);
+        size_t len = strlen(*line);
+        res = apr_pstrmemdup(atrans, *line, len);
+        *line += len;
         return res;
     }
 
index c71c5d8c771551d2a4c9a2cafdeb884a4ea847e1..b067f2096014a36ca71c5c6a23488eabebec71f3 100644 (file)
@@ -158,9 +158,9 @@ static const char *get_addresses(apr_pool_t *p, const char *w_,
     if (*w_ == '\0')
         return NULL;
 
-    w = apr_pstrdup(p, w_);
+    wlen = strlen(w_);                   /* wlen must be > 0 at this point */
+    w = apr_pstrmemdup(p, w_, wlen);
     /* apr_parse_addr_port() doesn't understand ":*" so handle that first. */
-    wlen = strlen(w);                    /* wlen must be > 0 at this point */
     wild_port = 0;
     if (w[wlen - 1] == '*') {
         if (wlen < 2) {