]> granicus.if.org Git - apache/commitdiff
shift the LimitXMLRequestBody directive to the core. use it from util_xml.
authorGreg Stein <gstein@apache.org>
Tue, 11 Jul 2000 00:06:22 +0000 (00:06 +0000)
committerGreg Stein <gstein@apache.org>
Tue, 11 Jul 2000 00:06:22 +0000 (00:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85816 13f79535-47bb-0310-9956-ffa450edef68

include/http_core.h
modules/dav/main/mod_dav.c
modules/http/http_core.c
server/util_xml.c

index e79e0e5121b73179f2200f4a726a0507245f5de9..8b30c236fc25ef61042c2f26bc2afff68e1a9f72 100644 (file)
@@ -135,6 +135,7 @@ API_EXPORT(char *) ap_construct_url(ap_pool_t *p, const char *uri, request_rec *
 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 @@ typedef struct {
     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,
index 9b03b41d544aa0a3ced57515a77973edb4d1ec1a..4e19fbe4715313578bb52e516b391d5aae6042f0 100644 (file)
@@ -107,7 +107,6 @@ typedef struct {
     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,10 +121,6 @@ typedef struct {
 #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 @@ static void *dav_create_dir_config(ap_pool_t *p, char *dir)
     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 @@ static void *dav_merge_dir_config(ap_pool_t *p, void *base, void *overrides)
     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 @@ ap_table_t *dav_get_dir_params(const request_rec *r)
     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;
@@ -339,21 +318,6 @@ static const char *dav_cmd_davparam(cmd_parms *cmd, void *config,
     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()
 **
@@ -3139,12 +3103,6 @@ static const command_rec dav_cmds[] =
                   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 }
 };
 
index 1e770ce5b291496f3dfe4995d838dca037f638c7..93d874fea2a6e05d1e77a9e17c3e0e84db9fd504 100644 (file)
 #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 @@ static void *create_core_dir_config(ap_pool_t *a, char *dir)
 #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 @@ static void *merge_core_dir_configs(ap_pool_t *a, void *basev, void *newv)
     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 @@ static const char *set_limit_req_body(cmd_parms *cmd, void *conf_,
     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("LimitRequestFields", set_limit_req_fields, NULL, RSRC_CONF,
 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,
index f9fd9ad78f9997cd72a5435bbbf0eda1ac0b5568..44897edaa5b86596f65daa7133c0d4d3199fa799 100644 (file)
@@ -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 @@ API_EXPORT(int) ap_xml_parse_input(request_rec * r, ap_xml_doc **pdoc)
        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);