Return-Path: Delivered-To: apmail-apache-cvs-archive@apache.org Received: (qmail 1504 invoked by uid 500); 11 Jul 2000 00:06:24 -0000 Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-cvs@apache.org Received: (qmail 1492 invoked by uid 500); 11 Jul 2000 00:06:23 -0000 Delivered-To: apmail-apache-2.0-cvs@apache.org Date: 11 Jul 2000 00:06:23 -0000 Message-ID: <20000711000623.1488.qmail@locus.apache.org> From: gstein@locus.apache.org To: apache-2.0-cvs@apache.org Subject: cvs commit: apache-2.0/src/modules/dav/main mod_dav.c gstein 00/07/10 17:06:22 Modified: src/main util_xml.c http_core.c src/include http_core.h src/modules/dav/main mod_dav.c Log: shift the LimitXMLRequestBody directive to the core. use it from util_xml. Revision Changes Path 1.7 +2 -1 apache-2.0/src/main/util_xml.c Index: util_xml.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/util_xml.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- util_xml.c 2000/07/03 22:28:34 1.6 +++ util_xml.c 2000/07/11 00:06:21 1.7 @@ -63,6 +63,7 @@ #include "httpd.h" #include "http_protocol.h" #include "http_log.h" +#include "http_core.h" #include "util_xml.h" @@ -395,7 +396,7 @@ char end; int rv; size_t total_read = 0; - size_t limit_xml_body = 1000000; /* ### fix this */ + size_t limit_xml_body = ap_get_limit_xml_body(r); /* allocate our working buffer */ buffer = ap_palloc(r->pool, AP_XML_READ_BLOCKSIZE); 1.87 +41 -0 apache-2.0/src/main/http_core.c Index: http_core.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- http_core.c 2000/07/10 21:49:21 1.86 +++ http_core.c 2000/07/11 00:06:21 1.87 @@ -111,6 +111,10 @@ #endif #endif /* USE_MMAP_FILES */ +/* LimitXMLRequestBody handling */ +#define AP_LIMIT_UNSET ((long) -1) +#define AP_DEFAULT_LIMIT_XML_BODY ((size_t)1000000) + /* 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. @@ -164,6 +168,7 @@ #endif conf->limit_req_body = 0; + conf->limit_xml_body = AP_LIMIT_UNSET; conf->sec = ap_make_array(a, 2, sizeof(void *)); #ifdef WIN32 conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET; @@ -285,6 +290,12 @@ if (new->limit_req_body) { conf->limit_req_body = new->limit_req_body; } + + if (new->limit_xml_body != AP_LIMIT_UNSET) + conf->limit_xml_body = new->limit_xml_body; + else + conf->limit_xml_body = base->limit_xml_body; + conf->sec = ap_append_arrays(a, base->sec, new->sec); if (new->satisfy != SATISFY_NOSPEC) { @@ -2369,6 +2380,32 @@ return NULL; } +static const char *set_limit_xml_req_body(cmd_parms *cmd, void *conf_, + const char *arg) +{ + core_dir_config *conf = conf_; + const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT); + if (err != NULL) { + return err; + } + + conf->limit_xml_body = atol(arg); + if (conf->limit_xml_body < 0) + return "LimitXMLRequestBody requires a non-negative integer."; + + return NULL; +} + +API_EXPORT(size_t) ap_get_limit_xml_body(const request_rec *r) +{ + core_dir_config *conf; + + conf = ap_get_module_config(r->per_dir_config, &core_module); + if (conf->limit_xml_body == AP_LIMIT_UNSET) + return AP_DEFAULT_LIMIT_XML_BODY; + return (size_t)conf->limit_xml_body; +} + #ifdef WIN32 static const char *set_interpreter_source(cmd_parms *cmd, core_dir_config *d, char *arg) @@ -2579,6 +2616,10 @@ AP_INIT_TAKE1("LimitRequestBody", set_limit_req_body, (void*)XtOffsetOf(core_dir_config, limit_req_body), OR_ALL, "Limit (in bytes) on maximum size of request message body"), +AP_INIT_TAKE1("LimitXMLRequestBody", set_limit_xml_req_body, NULL, OR_ALL, + "Limit (in bytes) on maximum size of an XML-based request " + "body"), + /* System Resource Controls */ #ifdef RLIMIT_CPU AP_INIT_TAKE12("RLimitCPU", set_limit_cpu, 1.21 +2 -0 apache-2.0/src/include/http_core.h Index: http_core.h =================================================================== RCS file: /home/cvs/apache-2.0/src/include/http_core.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- http_core.h 2000/06/28 07:55:44 1.20 +++ http_core.h 2000/07/11 00:06:22 1.21 @@ -135,6 +135,7 @@ API_EXPORT(const char *) ap_get_server_name(request_rec *r); API_EXPORT(unsigned) ap_get_server_port(const request_rec *r); API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r); +API_EXPORT(size_t) ap_get_limit_xml_body(const request_rec *r); API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string); API_EXPORT(int) ap_exists_config_define(const char *name); API_EXPORT_NONSTD(int) ap_core_translate(request_rec *r); @@ -270,6 +271,7 @@ struct rlimit *limit_nproc; #endif unsigned long limit_req_body; /* limit on bytes in request msg body */ + long limit_xml_body; /* limit on bytes in XML request msg body */ /* logging options */ enum { srv_sig_unset, srv_sig_off, srv_sig_on, 1.13 +0 -42 apache-2.0/src/modules/dav/main/mod_dav.c Index: mod_dav.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/dav/main/mod_dav.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- mod_dav.c 2000/07/10 07:49:47 1.12 +++ mod_dav.c 2000/07/11 00:06:22 1.13 @@ -107,7 +107,6 @@ int locktimeout; int handle_get; /* cached from repository hook structure */ int allow_depthinfinity; - long limit_xml_body; ap_table_t *d_params; /* per-directory DAV config parameters */ @@ -122,11 +121,7 @@ #define DAV_INHERIT_VALUE(parent, child, field) \ ((child)->field ? (child)->field : (parent)->field) -/* LimitXMLRequestBody handling */ -#define DAV_LIMIT_UNSET ((long) -1) -#define DAV_DEFAULT_LIMIT_XML_BODY ((size_t)1000000) - /* forward-declare for use in configuration lookup */ extern module MODULE_VAR_EXPORT dav_module; @@ -175,7 +170,6 @@ conf = (dav_dir_conf *) ap_pcalloc(p, sizeof(*conf)); conf->dir = ap_pstrdup(p, dir); conf->d_params = ap_make_table(p, 1); - conf->limit_xml_body = DAV_LIMIT_UNSET; return conf; } @@ -195,11 +189,6 @@ newconf->allow_depthinfinity = DAV_INHERIT_VALUE(parent, child, allow_depthinfinity); - if (child->limit_xml_body != DAV_LIMIT_UNSET) - newconf->limit_xml_body = child->limit_xml_body; - else - newconf->limit_xml_body = parent->limit_xml_body; - newconf->d_params = ap_copy_table(p, parent->d_params); ap_overlap_tables(newconf->d_params, child->d_params, AP_OVERLAP_TABLES_SET); @@ -224,16 +213,6 @@ return conf->d_params; } -size_t dav_get_limit_xml_body(const request_rec *r) -{ - dav_dir_conf *conf; - - conf = ap_get_module_config(r->per_dir_config, &dav_module); - if (conf->limit_xml_body == DAV_LIMIT_UNSET) - return DAV_DEFAULT_LIMIT_XML_BODY; - return (size_t)conf->limit_xml_body; -} - const dav_hooks_locks *dav_get_lock_hooks(request_rec *r) { void *data; @@ -340,21 +319,6 @@ } /* - * Command handler for LimitXMLRequestBody directive, which is TAKE1 - */ -static const char *dav_cmd_limitxmlrequestbody(cmd_parms *cmd, void *config, - const char *arg1) -{ - dav_dir_conf *conf = (dav_dir_conf *) config; - - conf->limit_xml_body = atol(arg1); - if (conf->limit_xml_body < 0) - return "LimitXMLRequestBody requires a non-negative integer."; - - return NULL; -} - -/* ** dav_error_response() ** ** Send a nice response back to the user. In most cases, Apache doesn't @@ -3138,12 +3102,6 @@ AP_INIT_TAKE2("DAVParam", dav_cmd_davparam, NULL, ACCESS_CONF|RSRC_CONF, "DAVParam "), - - /* per directory/location, or per server */ - AP_INIT_TAKE1("LimitXMLRequestBody", dav_cmd_limitxmlrequestbody, NULL, - ACCESS_CONF|RSRC_CONF, - "Limit (in bytes) on maximum size of an XML-based request " - "body"), { NULL } };