]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move "attr" to unsigned int
authorAlan T. DeKok <aland@freeradius.org>
Wed, 12 Aug 2009 08:10:45 +0000 (10:10 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 12 Aug 2009 08:10:45 +0000 (10:10 +0200)
So that we don't have to worry about whether or not the high bit is set

src/include/libradius.h
src/lib/dict.c
src/lib/radius.c

index 31235225b5a2d6099992e6323a8a9fea25cd6af6..a01780240bbb599894803d603d8bf692cba5d871 100644 (file)
@@ -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);
 
index 48368287858623abbb68fd862e4e7912bab1e981..262c110e41124d0fcf12f2fbe1dd6321cb21c1d2 100644 (file)
@@ -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];
index 09094c176885770152acd5e49f9e6c73afe1ccfc..082e900cfdd713700d9a1a61c520172ee515574c 100644 (file)
@@ -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)
                             
 {