]> granicus.if.org Git - apache/commitdiff
This patch zero-fills just the integer and pointer fields in
authorIan Holsman <ianh@apache.org>
Sun, 11 Nov 2001 22:12:25 +0000 (22:12 +0000)
committerIan Holsman <ianh@apache.org>
Sun, 11 Nov 2001 22:12:25 +0000 (22:12 +0000)
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 <bpane@pacbell.net>
Reviewed by: Ian Holsman

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

modules/filters/mod_include.c
modules/filters/mod_include.h

index b8156425465ff4574e53b9786982ca5b7a92b868..9768022a680df236e3a004ba01b9e9d91c3e0ace 100644 (file)
@@ -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);
index 5175d60c66716a33af315c72c2a91b91657ccbd2..2105e1c3ab826ed3d4cc28cae4e692ccb583a35e 100644 (file)
@@ -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 @@ 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) {                                       \