Parse raw attributes with 2-octet attribute numbers
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 Nov 2010 09:14:28 +0000 (10:14 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 22 Nov 2010 09:29:15 +0000 (10:29 +0100)
And enforce limitations on attribute numbers

src/lib/dict.c
src/lib/valuepair.c
src/tests/lucent.txt

index b5ff7b5..6c23180 100644 (file)
@@ -956,7 +956,11 @@ int dict_str2oid(const char *ptr, unsigned int *pvalue, int vendor, int tlv_dept
                return 0;
        }
 
-       *pvalue |= (value & fr_attr_mask[tlv_depth]) << fr_attr_shift[tlv_depth];
+       if (*pvalue) {
+               *pvalue |= (value & fr_attr_mask[tlv_depth]) << fr_attr_shift[tlv_depth];
+       } else {
+               *pvalue = value;
+       }
 
        if (p) {
                return dict_str2oid(p + 1, pvalue, vendor, tlv_depth + 1);
@@ -1008,10 +1012,17 @@ static int process_attribute(const char* fn, const int line,
                return -1;
        }
 
-       /*
-        *      Parse NUM.NUM.NUM.NUM
-        */
-       if (p) {
+       if (!p) {
+               if (value > (1 <<24)) {
+                       fr_strerror_printf("dict_init: %s[%d]: Attribute number is too large", fn, line);
+                       return -1;
+               }
+
+               
+               /*
+                *      Parse NUM.NUM.NUM.NUM
+                */
+       } else {
                DICT_ATTR *da;
 
                *p = '.';       /* reset for later printing */
index e7d158b..113adfc 100644 (file)
@@ -1404,6 +1404,7 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
                                break;
 
                        case 4:
+                               if (attr > (1 << 24)) goto attr_error;
                                break;
 
                        default:
index feba349..e21d03c 100644 (file)
@@ -6,3 +6,6 @@ data Lucent-Max-Shared-Users = 1
 
 decode 1a 0d 00 00 12 ee ff 02 07 00 00 00 01
 data Attr-26.4846.65282 = 0x00000001
+
+encode -
+data 1a 0d 00 00 12 ee ff 02 07 00 00 00 01