From: Ian Holsman Date: Sun, 11 Nov 2001 22:12:25 +0000 (+0000) Subject: This patch zero-fills just the integer and pointer fields in X-Git-Tag: 2.0.29~184 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=911ad32b82d9856ecd37cf2306dd2650b4d330d2;p=thirdparty%2Fapache%2Fhttpd.git This patch zero-fills just the integer and pointer fields in the structure, plus the first byte of each of the string buffers. This updated version of the patch doesn't allocate space for the error_str and time_str buffers in the mod_include filter context until/unless they're actually needed. --Brian Submitted by: Brian Pane Reviewed by: Ian Holsman git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91859 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c index b8156425465..9768022a680 100644 --- a/modules/filters/mod_include.c +++ b/modules/filters/mod_include.c @@ -1248,14 +1248,22 @@ static int handle_config(include_ctx_t *ctx, apr_bucket_brigade **bb, } } if (!strcmp(tag, "errmsg")) { - ap_ssi_parse_string(r, tag_val, ctx->error_str, + if (ctx->error_str_override == NULL) { + ctx->error_str_override = (char *)apr_palloc(ctx->pool, + MAX_STRING_LEN); + ctx->error_str = ctx->error_str_override; + } + ap_ssi_parse_string(r, tag_val, ctx->error_str_override, MAX_STRING_LEN, 0); - ctx->error_length = strlen(ctx->error_str); } else if (!strcmp(tag, "timefmt")) { apr_time_t date = r->request_time; - - ap_ssi_parse_string(r, tag_val, ctx->time_str, + if (ctx->time_str_override == NULL) { + ctx->time_str_override = (char *)apr_palloc(ctx->pool, + MAX_STRING_LEN); + ctx->time_str = ctx->time_str_override; + } + ap_ssi_parse_string(r, tag_val, ctx->time_str_override, MAX_STRING_LEN, 0); apr_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, ctx->time_str, 0)); @@ -3025,11 +3033,9 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b) ctx->ssi_tag_brigade = apr_brigade_create(f->c->pool); ctx->status = APR_SUCCESS; - apr_cpystrn(ctx->error_str, conf->default_error_msg, - sizeof(ctx->error_str)); - apr_cpystrn(ctx->time_str, conf->default_time_fmt, - sizeof(ctx->time_str)); - ctx->error_length = strlen(ctx->error_str); + ctx->error_str = conf->default_error_msg; + ctx->time_str = conf->default_time_fmt; + ctx->pool = f->c->pool; } else { return ap_pass_brigade(f->next, b); diff --git a/modules/filters/mod_include.h b/modules/filters/mod_include.h index 5175d60c667..2105e1c3ab8 100644 --- a/modules/filters/mod_include.h +++ b/modules/filters/mod_include.h @@ -59,6 +59,8 @@ #ifndef _MOD_INCLUDE_H #define _MOD_INCLUDE_H 1 +#include "apr_pools.h" + #define STARTING_SEQUENCE "" @@ -155,9 +157,11 @@ typedef struct include_filter_ctx { apr_size_t directive_length; apr_size_t tag_length; - apr_size_t error_length; - char error_str[MAX_STRING_LEN]; - char time_str[MAX_STRING_LEN]; + char *error_str; + char *error_str_override; + char *time_str; + char *time_str_override; + apr_pool_t *pool; apr_bucket_brigade *ssi_tag_brigade; } include_ctx_t; @@ -177,7 +181,7 @@ typedef struct include_filter_ctx { { \ apr_size_t e_wrt; \ t_buck = apr_bucket_heap_create(cntx->error_str, \ - cntx->error_length, 1, &e_wrt); \ + strlen(cntx->error_str), 1, &e_wrt); \ APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \ \ if (ins_head == NULL) { \