APACHE 1.3 STATUS: -*-text-*-
- Last modified at [$Date: 2004/03/29 18:25:03 $]
+ Last modified at [$Date: 2004/03/29 18:35:29 $]
Release:
* PR: 27023 Cookie could not delivered if the cookie made before
proxy module.
- * ap_custom_response memory corruption
- discussion:
- Message-ID: <4062E7F3.7010707@attglobal.net>
- Subject: [1.3 PATCH] fix ap_custom_response() memory corruption issue
- patch:
- http://www.apache.org/~trawick/13_custom_response_patch
- +1: trawick, stoddard, jim
-
RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
* isn't ap_die() broken with recognizing recursive errors
#define MMAP_LIMIT (4*1024*1024)
#endif
+typedef struct {
+ /* Custom response strings registered via ap_custom_response(),
+ * or NULL; check per-dir config if nothing found here
+ */
+ char **response_code_strings; /* from ap_custom_response(), not from
+ * ErrorDocument
+ */
+} core_request_config;
+
/* Server core module... This module provides support for really basic
* server operations, including options and commands which control the
* operation of other modules. Consider this the bureaucracy module.
API_EXPORT(char *) ap_response_code_string(request_rec *r, int error_index)
{
- core_dir_config *conf;
+ core_request_config *reqconf;
+ core_dir_config *dirconf;
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
+ /* prefer per-request settings, which are created by calls to
+ * ap_custom_response()
+ */
+ reqconf = (core_request_config *)ap_get_module_config(r->request_config,
+ &core_module);
- if (conf->response_code_strings == NULL) {
+ if (reqconf != NULL &&
+ reqconf->response_code_strings != NULL &&
+ reqconf->response_code_strings[error_index] != NULL) {
+ return reqconf->response_code_strings[error_index];
+ }
+
+ /* check for string specified via ErrorDocument */
+ dirconf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
+ &core_module);
+
+ if (dirconf->response_code_strings == NULL) {
return NULL;
}
- return conf->response_code_strings[error_index];
+
+ return dirconf->response_code_strings[error_index];
}
API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string)
{
- core_dir_config *conf =
- ap_get_module_config(r->per_dir_config, &core_module);
+ core_request_config *reqconf =
+ ap_get_module_config(r->request_config, &core_module);
int idx;
- if(conf->response_code_strings == NULL) {
- conf->response_code_strings =
+ if (reqconf == NULL) {
+ reqconf = (core_request_config *)ap_pcalloc(r->pool,
+ sizeof(core_request_config));
+ ap_set_module_config(r->request_config, &core_module, reqconf);
+ }
+
+ if (reqconf->response_code_strings == NULL) {
+ reqconf->response_code_strings =
ap_pcalloc(r->pool,
- sizeof(*conf->response_code_strings) *
- RESPONSE_CODES);
+ sizeof(reqconf->response_code_strings) *
+ RESPONSE_CODES);
}
idx = ap_index_of_response(status);
- conf->response_code_strings[idx] =
+ reqconf->response_code_strings[idx] =
((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
ap_pstrdup(r->pool, string) : ap_pstrcat(r->pool, "\"", string, NULL);
}