]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow 'length=uint16' as a flag for STRUCT
authorAlan T. DeKok <aland@freeradius.org>
Fri, 24 Sep 2021 15:52:38 +0000 (11:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 28 Sep 2021 12:45:19 +0000 (08:45 -0400)
because struct.c supports it, so why not...

src/lib/util/dict_tokenize.c

index b18e85951668506bcfcacd6c6af674b29f307f31..faf6eb98e76c2f3ac8f00a5e5a9caa938aa7f52c 100644 (file)
@@ -1373,7 +1373,7 @@ static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int a
        char                            *key_attr = argv[1];
        char                            *name = argv[0];
 
-       if (argc != 3) {
+       if ((argc < 3) || (argc > 4)) {
                fr_strerror_const("Invalid STRUCT syntax");
                return -1;
        }
@@ -1415,8 +1415,6 @@ static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int a
         */
        if (!fr_cond_assert(parent->parent->type == FR_TYPE_STRUCT)) return -1;
 
-       memset(&flags, 0, sizeof(flags));
-
        /*
         *      Parse the value.
         */
@@ -1425,6 +1423,21 @@ static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int a
                return -1;
        }
 
+       /*
+        *      Only a few flags are allowed for STRUCT.
+        */
+       memset(&flags, 0, sizeof(flags));
+
+       if (argc == 4) {
+               if (strcmp(argv[3], "length=uint16") != 0) {
+                       fr_strerror_printf("Unknown option '%s'", argv[3]);
+                       return -1;
+               }
+
+               flags.extra = 1;
+               flags.subtype = FLAG_LENGTH_UINT16;
+       }
+
        /*
         *      @todo - auto-number from a parent UNION, instead of overloading the value.
         */