From: Alan T. DeKok Date: Wed, 12 Aug 2009 08:10:45 +0000 (+0200) Subject: Move "attr" to unsigned int X-Git-Tag: release_2_1_7~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c85a0fbb04440fb7de1dd879b84d4611acc14105;p=thirdparty%2Ffreeradius-server.git Move "attr" to unsigned int So that we don't have to worry about whether or not the high bit is set --- diff --git a/src/include/libradius.h b/src/include/libradius.h index 31235225b5a..a01780240bb 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -115,7 +115,7 @@ typedef struct attr_flags { #define FLAG_ENCRYPT_ASCEND_SECRET (3) typedef struct dict_attr { - int attr; + unsigned int attr; int type; int vendor; ATTR_FLAGS flags; @@ -123,7 +123,7 @@ typedef struct dict_attr { } DICT_ATTR; typedef struct dict_value { - int attr; + unsigned int attr; int value; char name[1]; } DICT_VALUE; @@ -244,10 +244,10 @@ int dict_addattr(const char *name, int vendor, int type, int value, ATTR_FLAGS int dict_addvalue(const char *namestr, const char *attrstr, int value); int dict_init(const char *dir, const char *fn); void dict_free(void); -DICT_ATTR *dict_attrbyvalue(int attr); +DICT_ATTR *dict_attrbyvalue(unsigned int attr); DICT_ATTR *dict_attrbyname(const char *attr); -DICT_VALUE *dict_valbyattr(int attr, int val); -DICT_VALUE *dict_valbyname(int attr, const char *val); +DICT_VALUE *dict_valbyattr(unsigned int attr, int val); +DICT_VALUE *dict_valbyname(unsigned int attr, const char *val); int dict_vendorbyname(const char *name); DICT_VENDOR *dict_vendorbyvalue(int vendor); diff --git a/src/lib/dict.c b/src/lib/dict.c index 48368287858..262c110e411 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -1718,7 +1718,7 @@ int dict_init(const char *dir, const char *fn) /* * Get an attribute by its numerical value. */ -DICT_ATTR *dict_attrbyvalue(int attr) +DICT_ATTR *dict_attrbyvalue(unsigned int attr) { DICT_ATTR dattr; @@ -1749,7 +1749,7 @@ DICT_ATTR *dict_attrbyname(const char *name) /* * Associate a value with an attribute and return it. */ -DICT_VALUE *dict_valbyattr(int attr, int value) +DICT_VALUE *dict_valbyattr(unsigned int attr, int value) { DICT_VALUE dval, *dv; @@ -1774,7 +1774,7 @@ DICT_VALUE *dict_valbyattr(int attr, int value) /* * Get a value by its name, keyed off of an attribute. */ -DICT_VALUE *dict_valbyname(int attr, const char *name) +DICT_VALUE *dict_valbyname(unsigned int attr, const char *name) { DICT_VALUE *my_dv, *dv; uint32_t buffer[(sizeof(*my_dv) + DICT_VALUE_MAX_NAME_LEN + 3)/4]; diff --git a/src/lib/radius.c b/src/lib/radius.c index 09094c17688..082e900cfdd 100644 --- a/src/lib/radius.c +++ b/src/lib/radius.c @@ -424,8 +424,8 @@ static void make_secret(uint8_t *digest, const uint8_t *vector, } #define MAX_PASS_LEN (128) -static void make_passwd(uint8_t *output, int *outlen, - const uint8_t *input, int inlen, +static void make_passwd(uint8_t *output, size_t *outlen, + const uint8_t *input, size_t inlen, const char *secret, const uint8_t *vector) { FR_MD5_CTX context, old; @@ -480,8 +480,8 @@ static void make_passwd(uint8_t *output, int *outlen, memcpy(output, passwd, len); } -static void make_tunnel_passwd(uint8_t *output, int *outlen, - const uint8_t *input, int inlen, int room, +static void make_tunnel_passwd(uint8_t *output, size_t *outlen, + const uint8_t *input, size_t inlen, size_t room, const char *secret, const uint8_t *vector) { FR_MD5_CTX context, old; @@ -573,7 +573,7 @@ static void make_tunnel_passwd(uint8_t *output, int *outlen, static int vp2data(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const char *secret, const VALUE_PAIR *vp, uint8_t *ptr, - int offset, int room) + size_t offset, size_t room) { uint32_t lvalue; size_t len; @@ -741,7 +741,8 @@ static int vp2data(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, static VALUE_PAIR *rad_vp2tlv(VALUE_PAIR *vps) { int maxattr = 0; - int length, attribute; + int length; + unsigned int attribute; uint8_t *ptr; VALUE_PAIR *vp, *tlv; @@ -993,7 +994,7 @@ int rad_vp2attr(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, * * FIXME: Keep track of room in the packet! */ - if (vp->length > (254 - (ptr - start))) { + if (vp->length > (((size_t) 254) - (ptr - start))) { return rad_vp2continuation(vp, start, ptr); } @@ -2097,7 +2098,8 @@ int rad_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, static VALUE_PAIR *data2vp(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, - const char *secret, int attribute, int length, + const char *secret, + UNUSED unsigned int attribute, size_t length, const uint8_t *data, VALUE_PAIR *vp) { int offset = 0; @@ -2385,7 +2387,8 @@ static void rad_sortvp(VALUE_PAIR **head) * Sane clients should put the fragments next to each other, in * which case this is O(N), in the number of fragments. */ -static uint8_t *rad_coalesce(int attribute, size_t length, uint8_t *data, +static uint8_t *rad_coalesce(unsigned int attribute, size_t length, + uint8_t *data, size_t packet_length, size_t *ptlv_length) {