httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cody Sherr <csh...@covalent.net>
Subject [PATCH] <Limit> directives changes
Date Fri, 10 Aug 2001 23:57:36 GMT

Adding a macro for the 1 that is shifted to check for <Limit> masks.
1 is by default an int, so if it's shifted more than 32 it wraps around.
The macro casts the 1 to apr_int64_t, which is what is currently being
used for limit directives.

This allows things proper checking on methods that get registered > 32,
and ap_method_register(apr_hash_t registry, const char *methnam) 2nd arg
is now properly const (kudos to Ryan Morgan).

cheers,
-- 
Cody Sherr

Engineer
Covalent Technologies

phone: (415)536-5292
email: csherr@covalent.net

Index: include/http_protocol.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/http_protocol.h,v
retrieving revision 1.61
diff -u -r1.61 http_protocol.h
--- include/http_protocol.h	2001/08/02 04:25:19	1.61
+++ include/http_protocol.h	2001/08/10 23:44:14
@@ -246,7 +246,7 @@
  * @param methname The name of the new method to register.
  * @return         Ab int value representing an offset into a bitmask.
  */
-AP_DECLARE(int) ap_method_register(apr_pool_t *p, char *methname);
+AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname);

 /**
  * Initialize the method_registry and allocate memory for it.
@@ -259,7 +259,8 @@
  * This is a convenience macro to ease with checking a mask
  * against a method name.
  */
-#define AP_METHOD_CHECK_ALLOWED(mask, methname) ((mask) & (1 << ap_method_number_of((methname))))
+#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
+    ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))

 /**
  * Create a new method list with the specified number of preallocated
Index: include/httpd.h
===================================================================
RCS file: /home/cvspublic/httpd-2.0/include/httpd.h,v
retrieving revision 1.157
diff -u -r1.157 httpd.h
--- include/httpd.h	2001/08/02 04:25:19	1.157
+++ include/httpd.h	2001/08/10 23:44:14
@@ -503,6 +503,12 @@
  */
 #define METHODS     64

+/**
+ * The method mask bit to shift for anding with a bitmask.
+ */
+#define AP_METHOD_BIT (apr_int64_t)1
+
+
 typedef struct ap_method_list_t ap_method_list_t;
 /**
  * Structure for handling HTTP methods.  Methods known to the server are
Index: modules/aaa/mod_access.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/aaa/mod_access.c,v
retrieving revision 1.33
diff -u -r1.33 mod_access.c
--- modules/aaa/mod_access.c	2001/08/02 04:25:19	1.33
+++ modules/aaa/mod_access.c	2001/08/10 23:44:15
@@ -141,7 +141,7 @@
 	return "unknown order";

     for (i = 0; i < METHODS; ++i)
-	if (cmd->limited & (1 << i))
+	if (cmd->limited & (AP_METHOD_BIT << i))
 	    d->order[i] = o;

     return NULL;
@@ -239,7 +239,7 @@
 {

     allowdeny *ap = (allowdeny *) a->elts;
-    apr_int64_t mmask = (1 << method);
+    apr_int64_t mmask = (AP_METHOD_BIT << method);
     int i;
     int gothost = 0;
     const char *remotehost = NULL;
Index: modules/aaa/mod_auth.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/aaa/mod_auth.c,v
retrieving revision 1.33
diff -u -r1.33 mod_auth.c
--- modules/aaa/mod_auth.c	2001/02/25 00:51:30	1.33
+++ modules/aaa/mod_auth.c	2001/08/10 23:44:15
@@ -268,7 +268,7 @@

     for (x = 0; x < reqs_arr->nelts; x++) {

-	if (!(reqs[x].method_mask & (1 << m)))
+	if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
 	    continue;

 	method_restricted = 1;
Index: modules/aaa/mod_auth_db.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/aaa/mod_auth_db.c,v
retrieving revision 1.29
diff -u -r1.29 mod_auth_db.c
--- modules/aaa/mod_auth_db.c	2001/05/30 10:22:18	1.29
+++ modules/aaa/mod_auth_db.c	2001/08/10 23:44:15
@@ -360,7 +360,7 @@

     for (x = 0; x < reqs_arr->nelts; x++) {

-	if (!(reqs[x].method_mask & (1 << m)))
+	if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
 	    continue;

 	t = reqs[x].requirement;
Index: modules/aaa/mod_auth_dbm.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/aaa/mod_auth_dbm.c,v
retrieving revision 1.34
diff -u -r1.34 mod_auth_dbm.c
--- modules/aaa/mod_auth_dbm.c	2001/05/30 10:22:19	1.34
+++ modules/aaa/mod_auth_dbm.c	2001/08/10 23:44:15
@@ -299,7 +299,7 @@

     for (x = 0; x < reqs_arr->nelts; x++) {

-	if (!(reqs[x].method_mask & (1 << m)))
+	if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
 	    continue;

 	t = reqs[x].requirement;
Index: modules/aaa/mod_auth_digest.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/aaa/mod_auth_digest.c,v
retrieving revision 1.48
diff -u -r1.48 mod_auth_digest.c
--- modules/aaa/mod_auth_digest.c	2001/05/22 01:31:03	1.48
+++ modules/aaa/mod_auth_digest.c	2001/08/10 23:44:15
@@ -1851,7 +1851,7 @@

     for (x = 0; x < reqs_arr->nelts; x++) {

-	if (!(reqs[x].method_mask & (1 << m)))
+	if (!(reqs[x].method_mask & (AP_METHOD_BIT << m)))
 	    continue;

 	method_restricted = 1;
Index: modules/cache/mod_file_cache.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/cache/mod_file_cache.c,v
retrieving revision 1.61
diff -u -r1.61 mod_file_cache.c
--- modules/cache/mod_file_cache.c	2001/08/02 00:17:45	1.61
+++ modules/cache/mod_file_cache.c	2001/08/10 23:44:16
@@ -387,7 +387,7 @@
     }

     /* note that we would handle GET on this resource */
-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);

     /* This handler has no use for a request body (yet), but we still
      * need to read and discard it if the client sent one.
Index: modules/dav/main/mod_dav.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/dav/main/mod_dav.c,v
retrieving revision 1.58
diff -u -r1.58 mod_dav.c
--- modules/dav/main/mod_dav.c	2001/07/31 17:01:34	1.58
+++ modules/dav/main/mod_dav.c	2001/08/10 23:44:18
@@ -4466,28 +4466,28 @@
      * These are the HTTP-defined methods that we handle directly.
      */
     r->allowed = 0
-        | (1 << M_GET)
-	| (1 << M_PUT)
-	| (1 << M_DELETE)
-	| (1 << M_OPTIONS)
-	| (1 << M_INVALID);
+        | (AP_METHOD_BIT << M_GET)
+	| (AP_METHOD_BIT << M_PUT)
+	| (AP_METHOD_BIT << M_DELETE)
+	| (AP_METHOD_BIT << M_OPTIONS)
+	| (AP_METHOD_BIT << M_INVALID);
     /*
      * These are the DAV methods we handle.
      */
     r->allowed |= 0
-	| (1 << M_COPY)
-	| (1 << M_LOCK)
-	| (1 << M_UNLOCK)
-	| (1 << M_MKCOL)
-	| (1 << M_MOVE)
-	| (1 << M_PROPFIND)
-	| (1 << M_PROPPATCH);
+	| (AP_METHOD_BIT << M_COPY)
+	| (AP_METHOD_BIT << M_LOCK)
+	| (AP_METHOD_BIT << M_UNLOCK)
+	| (AP_METHOD_BIT << M_MKCOL)
+	| (AP_METHOD_BIT << M_MOVE)
+	| (AP_METHOD_BIT << M_PROPFIND)
+	| (AP_METHOD_BIT << M_PROPPATCH);
     /*
      * These are methods that we don't handle directly, but let the
      * server's default handler do for us as our agent.
      */
     r->allowed |= 0
-	| (1 << M_POST);
+	| (AP_METHOD_BIT << M_POST);

     /* ### hrm. if we return HTTP_METHOD_NOT_ALLOWED, then an Allow header
      * ### is sent; it will need the other allowed states; since the default
Index: modules/filters/mod_include.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/filters/mod_include.c,v
retrieving revision 1.120
diff -u -r1.120 mod_include.c
--- modules/filters/mod_include.c	2001/08/07 08:02:42	1.120
+++ modules/filters/mod_include.c	2001/08/10 23:44:21
@@ -2680,7 +2680,7 @@
     if (!(ap_allow_options(r) & OPT_INCLUDES)) {
         return ap_pass_brigade(f->next, b);
     }
-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET) {
         return ap_pass_brigade(f->next, b);
     }
Index: modules/generators/mod_asis.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_asis.c,v
retrieving revision 1.39
diff -u -r1.39 mod_asis.c
--- modules/generators/mod_asis.c	2001/07/27 19:58:15	1.39
+++ modules/generators/mod_asis.c	2001/08/10 23:44:21
@@ -79,7 +79,7 @@
     if(strcmp(r->handler,ASIS_MAGIC_TYPE) && strcmp(r->handler,"send-as-is"))
 	return DECLINED;

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET)
 	return DECLINED;
     if (r->finfo.filetype == 0) {
Index: modules/generators/mod_autoindex.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_autoindex.c,v
retrieving revision 1.82
diff -u -r1.82 mod_autoindex.c
--- modules/generators/mod_autoindex.c	2001/08/07 15:15:53	1.82
+++ modules/generators/mod_autoindex.c	2001/08/10 23:44:21
@@ -1994,7 +1994,7 @@
     d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
 						      &autoindex_module);

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET) {
 	return DECLINED;
     }
Index: modules/generators/mod_cgi.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_cgi.c,v
retrieving revision 1.98
diff -u -r1.98 mod_cgi.c
--- modules/generators/mod_cgi.c	2001/08/06 18:41:31	1.98
+++ modules/generators/mod_cgi.c	2001/08/10 23:44:21
@@ -586,8 +586,8 @@

     if (r->method_number == M_OPTIONS) {
 	/* 99 out of 100 CGI scripts, this is all they support */
-	r->allowed |= (1 << M_GET);
-	r->allowed |= (1 << M_POST);
+	r->allowed |= (AP_METHOD_BIT << M_GET);
+	r->allowed |= (AP_METHOD_BIT << M_POST);
 	return DECLINED;
     }

Index: modules/generators/mod_cgid.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_cgid.c,v
retrieving revision 1.91
diff -u -r1.91 mod_cgid.c
--- modules/generators/mod_cgid.c	2001/08/09 15:10:58	1.91
+++ modules/generators/mod_cgid.c	2001/08/10 23:44:21
@@ -857,8 +857,8 @@

     if (r->method_number == M_OPTIONS) {
         /* 99 out of 100 cgid scripts, this is all they support */
-        r->allowed |= (1 << M_GET);
-        r->allowed |= (1 << M_POST);
+        r->allowed |= (AP_METHOD_BIT << M_GET);
+        r->allowed |= (AP_METHOD_BIT << M_POST);
         return DECLINED;
     }

Index: modules/generators/mod_info.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_info.c,v
retrieving revision 1.39
diff -u -r1.39 mod_info.c
--- modules/generators/mod_info.c	2001/07/28 00:46:49	1.39
+++ modules/generators/mod_info.c	2001/08/10 23:44:22
@@ -373,7 +373,7 @@
     if (strcmp(r->handler, "server-info"))
         return DECLINED;

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET)
 	return DECLINED;

Index: modules/generators/mod_status.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/generators/mod_status.c,v
retrieving revision 1.45
diff -u -r1.45 mod_status.c
--- modules/generators/mod_status.c	2001/07/31 06:22:32	1.45
+++ modules/generators/mod_status.c	2001/08/10 23:44:22
@@ -270,7 +270,7 @@
 		    "Server status unavailable in inetd mode");
 	return HTTP_INTERNAL_SERVER_ERROR;
     }
-    r->allowed = (1 << M_GET);
+    r->allowed = (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET)
 	return DECLINED;

Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.352
diff -u -r1.352 http_protocol.c
--- modules/http/http_protocol.c	2001/08/10 18:35:08	1.352
+++ modules/http/http_protocol.c	2001/08/10 23:44:22
@@ -328,7 +328,7 @@
 			      apr_pool_cleanup_null);
 }

-AP_DECLARE(int) ap_method_register(apr_pool_t *p, char *methname)
+AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname)
 {
     int *newmethnum;

@@ -985,23 +985,23 @@

     mask = r->allowed_methods->method_mask;
     list = apr_pstrcat(r->pool,
-		       (mask & (1 << M_GET))	   ? ", GET, HEAD" : "",
-		       (mask & (1 << M_POST))	   ? ", POST"      : "",
-		       (mask & (1 << M_PUT))	   ? ", PUT"       : "",
-		       (mask & (1 << M_DELETE))	   ? ", DELETE"    : "",
-		       (mask & (1 << M_CONNECT))   ? ", CONNECT"   : "",
-		       (mask & (1 << M_OPTIONS))   ? ", OPTIONS"   : "",
-		       (mask & (1 << M_PATCH))	   ? ", PATCH"     : "",
-		       (mask & (1 << M_PROPFIND))  ? ", PROPFIND"  : "",
-		       (mask & (1 << M_PROPPATCH)) ? ", PROPPATCH" : "",
-		       (mask & (1 << M_MKCOL))	   ? ", MKCOL"     : "",
-		       (mask & (1 << M_COPY))	   ? ", COPY"      : "",
-		       (mask & (1 << M_MOVE))	   ? ", MOVE"      : "",
-		       (mask & (1 << M_LOCK))	   ? ", LOCK"      : "",
-		       (mask & (1 << M_UNLOCK))	   ? ", UNLOCK"    : "",
+		       (mask & (AP_METHOD_BIT << M_GET))	   ? ", GET, HEAD" : "",
+		       (mask & (AP_METHOD_BIT << M_POST))	   ? ", POST"      : "",
+		       (mask & (AP_METHOD_BIT << M_PUT))	   ? ", PUT"       : "",
+		       (mask & (AP_METHOD_BIT << M_DELETE))	   ? ", DELETE"    : "",
+		       (mask & (AP_METHOD_BIT << M_CONNECT))   ? ", CONNECT"   : "",
+		       (mask & (AP_METHOD_BIT << M_OPTIONS))   ? ", OPTIONS"   : "",
+		       (mask & (AP_METHOD_BIT << M_PATCH))	   ? ", PATCH"     : "",
+		       (mask & (AP_METHOD_BIT << M_PROPFIND))  ? ", PROPFIND"  : "",
+		       (mask & (AP_METHOD_BIT << M_PROPPATCH)) ? ", PROPPATCH" : "",
+		       (mask & (AP_METHOD_BIT << M_MKCOL))	   ? ", MKCOL"     : "",
+		       (mask & (AP_METHOD_BIT << M_COPY))	   ? ", COPY"      : "",
+		       (mask & (AP_METHOD_BIT << M_MOVE))	   ? ", MOVE"      : "",
+		       (mask & (AP_METHOD_BIT << M_LOCK))	   ? ", LOCK"      : "",
+		       (mask & (AP_METHOD_BIT << M_UNLOCK))	   ? ", UNLOCK"    : "",
 		       ", TRACE",
 		       NULL);
-    if ((mask & (1 << M_INVALID))
+    if ((mask & (AP_METHOD_BIT << M_INVALID))
 	&& (r->allowed_methods->method_list != NULL)
 	&& (r->allowed_methods->method_list->nelts != 0)) {
 	int i;
@@ -2089,7 +2089,7 @@
      */
     methnum = ap_method_number_of(method);
     if (methnum != M_INVALID) {
-        return !!(l->method_mask & (1 << methnum));
+        return !!(l->method_mask & (AP_METHOD_BIT << methnum));
     }
     /*
      * Otherwise, see if the method name is in the array or string names
@@ -2121,7 +2121,7 @@
      * bitmask.
      */
     methnum = ap_method_number_of(method);
-    l->method_mask |= (1 << methnum);
+    l->method_mask |= (AP_METHOD_BIT << methnum);
     if (methnum != M_INVALID) {
         return;
     }
@@ -2154,7 +2154,7 @@
      * by a module, use the bitmask.
      */
     methnum = ap_method_number_of(method);
-    l->method_mask |= ~(1 << methnum);
+    l->method_mask |= ~(AP_METHOD_BIT << methnum);
     if (methnum != M_INVALID) {
         return;
     }
Index: modules/mappers/mod_actions.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_actions.c,v
retrieving revision 1.23
diff -u -r1.23 mod_actions.c
--- modules/mappers/mod_actions.c	2001/02/16 13:38:28	1.23
+++ modules/mappers/mod_actions.c	2001/08/10 23:44:23
@@ -172,7 +172,7 @@
     /* Set allowed stuff */
     for (i = 0; i < METHODS; ++i) {
         if (conf->scripted[i])
-            r->allowed |= (1 << i);
+            r->allowed |= (AP_METHOD_BIT << i);
     }

     /* First, check for the method-handling scripts */
Index: modules/test/mod_autoindex.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/test/mod_autoindex.c,v
retrieving revision 1.12
diff -u -r1.12 mod_autoindex.c
--- modules/test/mod_autoindex.c	2001/07/25 21:34:15	1.12
+++ modules/test/mod_autoindex.c	2001/08/10 23:44:31
@@ -1670,7 +1670,7 @@
     d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
 						      &autoindex_module);

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET) {
 	return DECLINED;
     }
Index: modules/test/mod_rndchunk.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/test/mod_rndchunk.c,v
retrieving revision 1.7
diff -u -r1.7 mod_rndchunk.c
--- modules/test/mod_rndchunk.c	2001/02/28 15:24:08	1.7
+++ modules/test/mod_rndchunk.c	2001/08/10 23:44:31
@@ -100,7 +100,7 @@
     char buf[MAX_SEGMENT + 1];
     unsigned int len;

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET)
 	return DECLINED;

Index: modules/test/mod_test_util_uri.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/test/mod_test_util_uri.c,v
retrieving revision 1.11
diff -u -r1.11 mod_test_util_uri.c
--- modules/test/mod_test_util_uri.c	2001/08/02 05:25:53	1.11
+++ modules/test/mod_test_util_uri.c	2001/08/10 23:44:31
@@ -265,7 +265,7 @@
     unsigned total_failures;
     int i;

-    r->allowed |= (1 << M_GET);
+    r->allowed |= (AP_METHOD_BIT << M_GET);
     if (r->method_number != M_GET)
 	return DECLINED;

Index: server/config.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/config.c,v
retrieving revision 1.132
diff -u -r1.132 config.c
--- server/config.c	2001/08/03 00:59:01	1.132
+++ server/config.c	2001/08/10 23:44:31
@@ -362,7 +362,7 @@
      * added by a module and registered.
      */
     if (methnum != M_INVALID) {
-	return !!(cmd->limited & (1<<methnum));
+	return !!(cmd->limited & (AP_METHOD_BIT << methnum));
     }

     return 0; /* not found */
Index: server/core.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/core.c,v
retrieving revision 1.34
diff -u -r1.34 core.c
--- server/core.c	2001/08/07 16:19:03	1.34
+++ server/core.c	2001/08/10 23:44:32
@@ -1490,7 +1490,7 @@
              */
             methnum = ap_method_register(cmd->pool, method);
         }
-        limited |= (1 << methnum);
+        limited |= (AP_METHOD_BIT << methnum);
     }

     /* Killing two features with one function,
Index: server/request.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/server/request.c,v
retrieving revision 1.22
diff -u -r1.22 request.c
--- server/request.c	2001/08/07 02:34:42	1.22
+++ server/request.c	2001/08/10 23:44:33
@@ -1280,7 +1280,7 @@
     reqs = (require_line *) reqs_arr->elts;

     for (i = 0; i < reqs_arr->nelts; ++i)
-        if (reqs[i].method_mask & (1 << r->method_number))
+        if (reqs[i].method_mask & (AP_METHOD_BIT << r->method_number))
             return 1;

     return 0;


Mime
View raw message