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);
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,
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 */
#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;
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;
}
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);
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;
return NULL;
}
-/*
- * 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()
**
ACCESS_CONF|RSRC_CONF,
"DAVParam <parameter name> <parameter value>"),
- /* 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 }
};
#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.
#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;
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) {
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)
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,
#include "httpd.h"
#include "http_protocol.h"
#include "http_log.h"
+#include "http_core.h"
#include "util_xml.h"
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);