commit c85a0fbb04440fb7de1dd879b84d4611acc14105
Author: Alan T. DeKok <aland@freeradius.org>
Date:   Wed Aug 12 10:10:45 2009 +0200
References: c85a0fbb04440fb7de1dd879b84d4611acc14105

    Move "attr" to unsigned int
    
    So that we don't have to worry about whether or not the high bit is set

Acked-by: Libor Pechacek <lpechacek@suse.cz>

---
 src/include/libradius.h |   10 +++++-----
 src/lib/dict.c          |    6 +++---
 src/lib/radius.c        |   21 ++++++++++++---------
 3 files changed, 20 insertions(+), 17 deletions(-)

--- freeradius-server-2.1.1.orig/src/include/libradius.h
+++ freeradius-server-2.1.1/src/include/libradius.h
@@ -115,7 +115,7 @@
 #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 @@
 } DICT_ATTR;
 
 typedef struct dict_value {
-	int			attr;
+	unsigned int		attr;
 	int			value;
 	char			name[1];
 } DICT_VALUE;
@@ -243,10 +243,10 @@
 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);
 
--- freeradius-server-2.1.1.orig/src/lib/dict.c
+++ freeradius-server-2.1.1/src/lib/dict.c
@@ -1737,7 +1737,7 @@
 /*
  *	Get an attribute by its numerical value.
  */
-DICT_ATTR *dict_attrbyvalue(int attr)
+DICT_ATTR *dict_attrbyvalue(unsigned int attr)
 {
 	DICT_ATTR dattr;
 
@@ -1768,7 +1768,7 @@
 /*
  *	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;
 
@@ -1793,7 +1793,7 @@
 /*
  *	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];
--- freeradius-server-2.1.1.orig/src/lib/radius.c
+++ freeradius-server-2.1.1/src/lib/radius.c
@@ -426,8 +426,8 @@
 }
 
 #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 @@
 	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 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 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 @@
 			 *
 			 *	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);
 			}
 
@@ -2091,7 +2092,8 @@
 
 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;
@@ -2379,7 +2381,8 @@
  *	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)
 			     
 {
