From: Alan T. DeKok Date: Fri, 24 Sep 2021 15:52:38 +0000 (-0400) Subject: allow 'length=uint16' as a flag for STRUCT X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3faa3c4e20cff692327acf62737f39c34d32cab1;p=thirdparty%2Ffreeradius-server.git allow 'length=uint16' as a flag for STRUCT because struct.c supports it, so why not... --- diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index b18e859516..faf6eb98e7 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -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. */