]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set the correct type size at the dict root, too
authorAlan T. DeKok <aland@freeradius.org>
Fri, 1 Nov 2019 18:48:30 +0000 (14:48 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 1 Nov 2019 18:48:46 +0000 (14:48 -0400)
src/lib/util/dict_tokenize.c

index 308a6b7dfed1d29ede71197c716dcf283129fd15..4efad66ac7cf3e7f28664f40ff418d205809cffb 100644 (file)
@@ -1151,7 +1151,7 @@ static int dict_read_parse_format(char const *format, unsigned int *pvalue, int
 static int dict_read_process_protocol(char **argv, int argc)
 {
        unsigned int    value;
-       unsigned int    type_size = 1;
+       unsigned int    type_size = 0;
        fr_dict_t       *dict;
        fr_dict_attr_t  *mutable;
 
@@ -1169,7 +1169,7 @@ static int dict_read_process_protocol(char **argv, int argc)
        }
 
        /*
-        *      255 protocolss FR_TYPE_GROUP type_size hack
+        *      255 protocols FR_TYPE_GROUP type_size hack
         */
        if ((value == 0) || (value > 255)) {
                fr_strerror_printf("Invalid value '%u' following PROTOCOL", value);
@@ -1228,7 +1228,8 @@ static int dict_read_process_protocol(char **argv, int argc)
         *      And check types no matter what.
         */
        if (dict) {
-               if (dict->root->flags.type_size != type_size) {
+               if (type_size && (dict->root->flags.type_size != type_size)) {
+               conflicting:
                        fr_strerror_printf("Conflicting flags for PROTOCOL \"%s\" (current %d versus new %d)",
                                           dict->root->name, dict->root->flags.type_size, type_size);
                        return -1;
@@ -1243,10 +1244,22 @@ static int dict_read_process_protocol(char **argv, int argc)
         */
        dict_root_set(dict, argv[0], value);
 
+       if (dict_protocol_add(dict) < 0) return -1;
+
+       /*
+        *      Set the type size
+        */
+       if (type_size && (dict->root->flags.type_size != type_size)) goto conflicting;
+
        memcpy(&mutable, &dict->root, sizeof(mutable));
-       mutable->flags.type_size = type_size;
 
-       if (dict_protocol_add(dict) < 0) return -1;
+       if (!type_size) {
+               mutable->flags.type_size = dict->default_type_size;
+               mutable->flags.length = dict->default_type_length;
+       } else {
+               mutable->flags.type_size = type_size;
+               mutable->flags.length = 1; /* who knows... */
+       }
 
        return 0;
 }