]> granicus.if.org Git - apache/commitdiff
Fix the new method code. We need to cast 1 to an apr_int64_t or it will
authorRyan Bloom <rbb@apache.org>
Sat, 11 Aug 2001 04:04:13 +0000 (04:04 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 11 Aug 2001 04:04:13 +0000 (04:04 +0000)
be treated as a 32-bit integer, and it will wrap after being shifted
32 times.
Submitted by: Cody Sherr <csherr@covalent.net> and
Ryan Morgan <rmorgan@covalent.net>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90090 13f79535-47bb-0310-9956-ffa450edef68

24 files changed:
include/http_protocol.h
include/httpd.h
modules/aaa/mod_access.c
modules/aaa/mod_auth.c
modules/aaa/mod_auth_db.c
modules/aaa/mod_auth_dbm.c
modules/aaa/mod_auth_digest.c
modules/cache/mod_file_cache.c
modules/dav/main/mod_dav.c
modules/filters/mod_include.c
modules/generators/mod_asis.c
modules/generators/mod_autoindex.c
modules/generators/mod_cgi.c
modules/generators/mod_cgid.c
modules/generators/mod_info.c
modules/generators/mod_status.c
modules/http/http_protocol.c
modules/mappers/mod_actions.c
modules/test/mod_autoindex.c
modules/test/mod_rndchunk.c
modules/test/mod_test_util_uri.c
server/config.c
server/core.c
server/request.c

index a27d5e77b89d5e039faa88b8d4b5311e0aeb45c5..b2754ed910e5daaf0784a977d49ac378145c8bff 100644 (file)
@@ -246,7 +246,7 @@ AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
  * @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 @@ AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p);
  * 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 e32ed8ef4a2a2fea7cb76736c9e149abd7d06e97..254c098ea5b71f1a7015a2ca4351160a0dd8f47a 100644 (file)
@@ -503,6 +503,12 @@ AP_DECLARE(const char *) ap_get_server_built(void);
  */
 #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 41d6133879ff7ab7642a61900fd3bccab96b018f..6b77006e5309e78a8016bc75a5ae1c1510b9c0c5 100644 (file)
@@ -141,7 +141,7 @@ static const char *order(cmd_parms *cmd, void *dv, const char *arg)
        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 @@ static int find_allowdeny(request_rec *r, apr_array_header_t *a, int method)
 {
 
     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 c3768a45fbe167e70f7e15c7182f50a5fbb722e4..482b0249d4e266da5559968392b3b9767e5b040c 100644 (file)
@@ -268,7 +268,7 @@ static int check_user_access(request_rec *r)
 
     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 a39112e20c9921b5c0415bb60c2f21dfddafeb3d..3c135312806cc28a65de1d7dc905644b64986f56 100644 (file)
@@ -360,7 +360,7 @@ static int db_check_auth(request_rec *r)
 
     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 25529b1b3373bbe5983a6bcb6b2ab64be62688b1..3d110e9659dcd26d15957d904827bd43fa8f929b 100644 (file)
@@ -299,7 +299,7 @@ static int dbm_check_auth(request_rec *r)
 
     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 1cbdc4facc5966e801b5d76b896d6ad7830a8fa0..d7326370bac1b42116ea3febf0789008f46e6dd6 100644 (file)
@@ -1851,7 +1851,7 @@ static int digest_check_auth(request_rec *r)
 
     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 0de8efb279481c40e7a4adc9e7ae9f538251e2da..568e059098e606f54f6c6ed16a10f19384be0d18 100644 (file)
@@ -387,7 +387,7 @@ static int file_cache_handler(request_rec *r)
     }
 
     /* 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 5423affb2dd9d15800f95ffa60b944eb528716d0..aa1f8ffedb6ed35c29c9c663dcb4dd165737f9e2 100644 (file)
@@ -4466,28 +4466,28 @@ static int dav_handler(request_rec *r)
      * 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 a20daea4ee194e4c68d4aac5f574cbcfe9b96df0..ac71a5b9e248bfbabafccea6d26da4323c35ea9e 100644 (file)
@@ -2680,7 +2680,7 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
     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 c5fcdc5042e9d9d2fbef1a41f7359262b9b4c59f..346b43511330800f25bd47e0b69a5e15d8a75917 100644 (file)
@@ -79,7 +79,7 @@ static int asis_handler(request_rec *r)
     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 80a3a66d7f63518cf06ebb8b0fd2a71c36f27c97..407ce555e708892db25366851d835959b00c45bb 100644 (file)
@@ -1994,7 +1994,7 @@ static int handle_autoindex(request_rec *r)
     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 13fc514d0f0e2821d9c8ce7b095cad2bd69d38e2..d54da1d95b412df15c9e3b461268b8f9276b4ab0 100644 (file)
@@ -586,8 +586,8 @@ static int cgi_handler(request_rec *r)
 
     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 26946a9657388e2fc1cd20509d26b76f9a01874c..900a8f4ca5ffa2d8df3355550726bfd3e1cbf125 100644 (file)
@@ -857,8 +857,8 @@ static int cgid_handler(request_rec *r)
 
     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 3cf4ffdf5b4968aa2f3b9ce736c9778ee261285b..515dd84147873d965e02fcf8a4f2befb62b5e20f 100644 (file)
@@ -373,7 +373,7 @@ static int display_info(request_rec *r)
     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 b713ee3cb795dd123897b28a71c049a22f0db69d..6681bc9d3154bb94d59f0d71435f953f61a18f1d 100644 (file)
@@ -270,7 +270,7 @@ static int status_handler(request_rec *r)
                    "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 f178fa4eb315e98296bedac078fec5a8aaa95e6b..1c00260783059e79e985d194fbdd26e6ebacf341 100644 (file)
@@ -328,7 +328,7 @@ AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p)
                              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 @@ static char *make_allow(request_rec *r)
 
     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 @@ AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method)
      */
     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 @@ AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method)
      * 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 @@ AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l,
      * 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 d6a31ddeb1022b7d441ea237d9b358bbade5ad99..2eb411be34d21fd27645464d001f487a0c2fd5b7 100644 (file)
@@ -172,7 +172,7 @@ static int action_handler(request_rec *r)
     /* 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 f01365c04349237967a1888610d70f22583f0546..7489164148bb96fb474d01d00ad6efd599e2c5cc 100644 (file)
@@ -1670,7 +1670,7 @@ static int handle_autoindex(request_rec *r)
     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 6eeae175ac2f702acdc3ddf1815c11c123f088d7..c987a48a57a071b7a87bdb54698481e8e7c3a346 100644 (file)
@@ -100,7 +100,7 @@ static int send_rndchunk(request_rec *r)
     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 3baae44bbd3305ee48cf8b38b199fd48a4cc9162..ad76be0855d9ee1f499662552d730616abf1ac7d 100644 (file)
@@ -265,7 +265,7 @@ static int test_util_uri(request_rec *r)
     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 a8f1f26b5e9adff82a588eceef93309ce9efac6f..9d2850dd7e919db633e91c40168f8e28cb7f9438 100644 (file)
@@ -362,7 +362,7 @@ AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method) {
      * 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 f85f8834addb71287faa6d90f47e65abe0c1479d..e0bff5f2854189504a852d93b6812be7fd6b607f 100644 (file)
@@ -1490,7 +1490,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dumm
              */
             methnum = ap_method_register(cmd->pool, method);
         }
-        limited |= (1 << methnum);
+        limited |= (AP_METHOD_BIT << methnum);
     }
 
     /* Killing two features with one function,
index fee0eff300f4c8eba4a8014f12696661e7391575..a7e67d194d1c9870d1b987a1a5562219ffc8d3b6 100644 (file)
@@ -1280,7 +1280,7 @@ AP_DECLARE(int) ap_some_auth_required(request_rec *r)
     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;