]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
cross-check name/number for PROTOCOL definition
authorAlan T. DeKok <aland@freeradius.org>
Mon, 13 May 2019 13:04:30 +0000 (09:04 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 13 May 2019 15:45:25 +0000 (11:45 -0400)
src/lib/util/dict.c

index 469508ae40dbe5643a105d9bbc25d03594fd60eb..a3fff73ffef200d569d89c6e8794b51ca190b88d 100644 (file)
@@ -4389,6 +4389,11 @@ static int dict_read_process_protocol(char **argv, int argc)
                return -1;
        }
 
+       if (value == 0) {
+               fr_strerror_printf("Invalid value '%u' following PROTOCOL", value);
+               return -1;
+       }
+
        /*
         *      Look for a format statement.  This may specify the
         *      type length of the protocol's types.
@@ -4410,7 +4415,30 @@ static int dict_read_process_protocol(char **argv, int argc)
                }
        }
 
-       dict = fr_dict_by_protocol_num(value);
+       /*
+        *      Cross check name / number.
+        */
+       dict = fr_dict_by_protocol_name(argv[0]);
+       if (dict) {
+               if (dict->root->attr != value) {
+                       fr_strerror_printf("Conflicting numbers %u vs %u for PROTOCOL \"%s\"",
+                                          dict->root->attr, value, dict->root->name);
+                       return -1;
+               }
+
+       } else {
+               dict = fr_dict_by_protocol_num(value);
+
+               if (dict && (strcasecmp(dict->root->name, argv[0]) != 0)) {
+                       fr_strerror_printf("Conflicting names \"%s\" vs \"%s\" for PROTOCOL %u",
+                                          dict->root->name, argv[0], dict->root->attr);
+                       return -1;
+               }
+       }
+
+       /*
+        *      And check types no matter what.
+        */
        if (dict) {
                if (dict->root->flags.type_size != type_size) {
                        fr_strerror_printf("Conflicting flags for PROTOCOL \"%s\"", dict->root->name);