]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
error out of we can't find an appropriate parent
authorAlan T. DeKok <aland@freeradius.org>
Fri, 1 Nov 2019 14:47:54 +0000 (10:47 -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 f3cf192f924bf04dbcbbc1ae663879788ff1728c..308a6b7dfed1d29ede71197c716dcf283129fd15 100644 (file)
@@ -978,16 +978,24 @@ static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int a
         *      enclosing "struct": unwind until we do find the
         *      parent, OR until we hit the root of the dictionary.
         */
-       if (ctx->stack[ctx->stack_depth].da != parent->parent) {
+       if ((ctx->stack_depth > 1) && (ctx->stack[ctx->stack_depth].da != parent->parent)) {
                int i;
+               bool found = false;
 
                for (i = ctx->stack_depth - 1; i > 0; i--) {
                        if ((ctx->stack[i].da == parent->parent) ||
                            (ctx->stack[i].da->flags.is_root)) {
                                ctx->stack_depth = i;
+                               found = true;
                                break;
                        }
                }
+
+               if (!found) {
+                       fr_strerror_printf("Invalid STRUCT definition, unknown key attribute %s",
+                                          parent->name);
+                       return -1;
+               }
        }
 
        /*