]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
CID #1453692 - Check stack overrun *AFTER* incrementing ctx->stack_depth
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 15 Sep 2019 19:13:16 +0000 (14:13 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 15 Sep 2019 19:17:16 +0000 (14:17 -0500)
src/lib/util/dict_tokenize.c

index be2306a26f7792357c2cd7ce571a2d34fec8bd6b..7e2fb319370235cb1b5475110c8e30532a8e3e6c 100644 (file)
@@ -423,12 +423,13 @@ static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type
 
 static int dict_ctx_push(dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *da)
 {
+       ctx->stack_depth++;
+
        if (ctx->stack_depth >= MAX_STACK) {
                fr_strerror_printf_push("Attribute definitions are nested too deep.");
                return -1;
        }
 
-       ctx->stack_depth++;
        memset(&ctx->stack[ctx->stack_depth], 0, sizeof(ctx->stack[ctx->stack_depth]));
 
        ctx->stack[ctx->stack_depth].dict = ctx->stack[ctx->stack_depth - 1].dict;