Commit 836811b7 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

Fix the new method code. We need to cast 1 to an apr_int64_t or it will

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
parent ef1a66a0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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
+6 −0
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading