1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

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
This commit is contained in:
Stefan Fritsch
2011-06-22 20:45:34 +00:00
parent 255f723fef
commit 51692222f6
9 changed files with 16 additions and 18 deletions

View 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 * Get rid of the surrounding parens; later on when generating the
* filter, they'll be put back. * filter, they'll be put back.
*/ */
sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter+1); sec->filter = apr_pstrmemdup(cmd->pool, urld->lud_filter+1,
sec->filter[strlen(sec->filter)-1] = '\0'; strlen(urld->lud_filter)-2);
} }
else { else {
sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter); sec->filter = apr_pstrdup(cmd->pool, urld->lud_filter);

View File

@@ -770,7 +770,7 @@ static int hm_handler(request_rec *r)
ap_set_content_type(r, "text/plain"); ap_set_content_type(r, "text/plain");
ap_set_content_length(r, 2); ap_set_content_length(r, 2);
ap_rprintf(r, "OK"); ap_rputs("OK", r);
ap_rflush(r); ap_rflush(r);
return OK; return OK;

View File

@@ -719,8 +719,7 @@ static dav_error * dav_fs_get_resource(
/* make sure the URI does not have a trailing "/" */ /* make sure the URI does not have a trailing "/" */
len = strlen(r->uri); len = strlen(r->uri);
if (len > 1 && r->uri[len - 1] == '/') { if (len > 1 && r->uri[len - 1] == '/') {
s = apr_pstrdup(r->pool, r->uri); s = apr_pstrmemdup(r->pool, r->uri, len-1);
s[len - 1] = '\0';
resource->uri = s; resource->uri = s;
} }
else { else {

View File

@@ -160,8 +160,8 @@ static void *dav_create_dir_config(apr_pool_t *p, char *dir)
char *d; char *d;
apr_size_t l; apr_size_t l;
d = apr_pstrdup(p, dir); l = strlen(dir);
l = strlen(d); d = apr_pstrmemdup(p, dir, l);
if (l > 1 && d[l - 1] == '/') if (l > 1 && d[l - 1] == '/')
d[l - 1] = '\0'; d[l - 1] = '\0';
conf->dir = d; conf->dir = d;

View File

@@ -1759,7 +1759,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
/* fast exit */ /* fast exit */
if (varlen < 4) { if (varlen < 4) {
return apr_pstrdup(r->pool, ""); return "";
} }
result = NULL; result = NULL;
@@ -2211,7 +2211,7 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry)
/* fast exit */ /* fast exit */
if (inputlen == span) { if (inputlen == span) {
return apr_pstrdup(pool, input); return apr_pstrmemdup(pool, input, inputlen);
} }
/* well, actually something to do */ /* well, actually something to do */

View File

@@ -634,8 +634,7 @@ static int serf_handler(request_rec *r)
static int is_true(const char *w) static int is_true(const char *w)
{ {
if (strcasecmp(w, "on") == 0 || if (strcasecmp(w, "on") == 0 || strcmp(w, "1") == 0 ||
strcasecmp(w, "1") == 0 ||
strcasecmp(w, "true") == 0) strcasecmp(w, "true") == 0)
{ {
return 1; return 1;
@@ -678,8 +677,7 @@ static const char *add_pass(cmd_parms *cmd, void *vconf,
const char *x = ap_strchr_c(p, '='); const char *x = ap_strchr_c(p, '=');
if (x) { if (x) {
char *key = apr_pstrndup(cmd->pool, p, x-p); if (strncmp(p, "preservehost", x-p) == 0) {
if (strcmp(key, "preservehost") == 0) {
conf->preservehost = is_true(x+1); conf->preservehost = is_true(x+1);
} }
} }

View File

@@ -1682,8 +1682,8 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
return NULL; return NULL;
} }
url_copy = apr_pstrdup(p, url);
url_length = strlen(url); url_length = strlen(url);
url_copy = apr_pstrmemdup(p, url, url_length);
/* /*
* We need to find the start of the path and * We need to find the start of the path and

View File

@@ -670,8 +670,9 @@ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *atrans, const char **line,
char *res; char *res;
if (!pos) { if (!pos) {
res = apr_pstrdup(atrans, *line); size_t len = strlen(*line);
*line += strlen(*line); res = apr_pstrmemdup(atrans, *line, len);
*line += len;
return res; return res;
} }

View File

@@ -158,9 +158,9 @@ static const char *get_addresses(apr_pool_t *p, const char *w_,
if (*w_ == '\0') if (*w_ == '\0')
return NULL; 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. */ /* apr_parse_addr_port() doesn't understand ":*" so handle that first. */
wlen = strlen(w); /* wlen must be > 0 at this point */
wild_port = 0; wild_port = 0;
if (w[wlen - 1] == '*') { if (w[wlen - 1] == '*') {
if (wlen < 2) { if (wlen < 2) {