Skip to content

Commit 73d0844

Browse files
author
Stefan Fritsch
committed
Various code cleanup
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
1 parent a2748ce commit 73d0844

9 files changed

Lines changed: 16 additions & 18 deletions

File tree

modules/aaa/mod_authnz_ldap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,8 @@ static const char *mod_auth_ldap_parse_url(cmd_parms *cmd,
13781378
* Get rid of the surrounding parens; later on when generating the
13791379
* filter, they'll be put back.
13801380
*/
1381-
sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter+1);
1382-
sec->filter[strlen(sec->filter)-1] = '\0';
1381+
sec->filter = apr_pstrmemdup(cmd->pool, urld->lud_filter+1,
1382+
strlen(urld->lud_filter)-2);
13831383
}
13841384
else {
13851385
sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter);

modules/cluster/mod_heartmonitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static int hm_handler(request_rec *r)
770770

771771
ap_set_content_type(r, "text/plain");
772772
ap_set_content_length(r, 2);
773-
ap_rprintf(r, "OK");
773+
ap_rputs("OK", r);
774774
ap_rflush(r);
775775

776776
return OK;

modules/dav/fs/repos.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,7 @@ static dav_error * dav_fs_get_resource(
719719
/* make sure the URI does not have a trailing "/" */
720720
len = strlen(r->uri);
721721
if (len > 1 && r->uri[len - 1] == '/') {
722-
s = apr_pstrdup(r->pool, r->uri);
723-
s[len - 1] = '\0';
722+
s = apr_pstrmemdup(r->pool, r->uri, len-1);
724723
resource->uri = s;
725724
}
726725
else {

modules/dav/main/mod_dav.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ static void *dav_create_dir_config(apr_pool_t *p, char *dir)
160160
char *d;
161161
apr_size_t l;
162162

163-
d = apr_pstrdup(p, dir);
164-
l = strlen(d);
163+
l = strlen(dir);
164+
d = apr_pstrmemdup(p, dir, l);
165165
if (l > 1 && d[l - 1] == '/')
166166
d[l - 1] = '\0';
167167
conf->dir = d;

modules/mappers/mod_rewrite.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
17591759

17601760
/* fast exit */
17611761
if (varlen < 4) {
1762-
return apr_pstrdup(r->pool, "");
1762+
return "";
17631763
}
17641764

17651765
result = NULL;
@@ -2211,7 +2211,7 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry)
22112211

22122212
/* fast exit */
22132213
if (inputlen == span) {
2214-
return apr_pstrdup(pool, input);
2214+
return apr_pstrmemdup(pool, input, inputlen);
22152215
}
22162216

22172217
/* well, actually something to do */

modules/proxy/mod_serf.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,7 @@ static int serf_handler(request_rec *r)
634634

635635
static int is_true(const char *w)
636636
{
637-
if (strcasecmp(w, "on") == 0 ||
638-
strcasecmp(w, "1") == 0 ||
637+
if (strcasecmp(w, "on") == 0 || strcmp(w, "1") == 0 ||
639638
strcasecmp(w, "true") == 0)
640639
{
641640
return 1;
@@ -678,8 +677,7 @@ static const char *add_pass(cmd_parms *cmd, void *vconf,
678677
const char *x = ap_strchr_c(p, '=');
679678

680679
if (x) {
681-
char *key = apr_pstrndup(cmd->pool, p, x-p);
682-
if (strcmp(key, "preservehost") == 0) {
680+
if (strncmp(p, "preservehost", x-p) == 0) {
683681
conf->preservehost = is_true(x+1);
684682
}
685683
}

modules/proxy/proxy_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,8 +1682,8 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
16821682
return NULL;
16831683
}
16841684

1685-
url_copy = apr_pstrdup(p, url);
16861685
url_length = strlen(url);
1686+
url_copy = apr_pstrmemdup(p, url, url_length);
16871687

16881688
/*
16891689
* We need to find the start of the path and

server/util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,9 @@ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *atrans, const char **line,
670670
char *res;
671671

672672
if (!pos) {
673-
res = apr_pstrdup(atrans, *line);
674-
*line += strlen(*line);
673+
size_t len = strlen(*line);
674+
res = apr_pstrmemdup(atrans, *line, len);
675+
*line += len;
675676
return res;
676677
}
677678

server/vhost.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ static const char *get_addresses(apr_pool_t *p, const char *w_,
158158
if (*w_ == '\0')
159159
return NULL;
160160

161-
w = apr_pstrdup(p, w_);
161+
wlen = strlen(w_); /* wlen must be > 0 at this point */
162+
w = apr_pstrmemdup(p, w_, wlen);
162163
/* apr_parse_addr_port() doesn't understand ":*" so handle that first. */
163-
wlen = strlen(w); /* wlen must be > 0 at this point */
164164
wild_port = 0;
165165
if (w[wlen - 1] == '*') {
166166
if (wlen < 2) {

0 commit comments

Comments
 (0)