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
Index: modules/filters/mod_include.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.h,v
retrieving revision 1.22
diff -u -r1.22 mod_include.h
--- modules/filters/mod_include.h 2001/09/02 01:09:02 1.22
+++ modules/filters/mod_include.h 2001/11/10 19:23:42
@@ -59,6 +59,8 @@
#ifndef _MOD_INCLUDE_H
#define _MOD_INCLUDE_H 1
+#include "apr_pools.h"
+
#define STARTING_SEQUENCE "<!--#"
#define ENDING_SEQUENCE "-->"
@@ -155,9 +157,11 @@
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 @@
{ \
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) { \
Index: modules/filters/mod_include.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.150
diff -u -r1.150 mod_include.c
--- modules/filters/mod_include.c 2001/09/19 06:25:07 1.150
+++ modules/filters/mod_include.c 2001/11/10 19:23:44
@@ -1248,14 +1248,22 @@
}
}
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 @@
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);