From: Alan T. DeKok Date: Wed, 4 Sep 2024 14:58:05 +0000 (-0400) Subject: ensure that the data types in "foreach" are compatible X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=673539727be1ca2870d379422f6f72e75f687a2b;p=thirdparty%2Ffreeradius-server.git ensure that the data types in "foreach" are compatible --- diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index aaf27e09fc..c97ffd3bb3 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -3356,7 +3356,18 @@ static unlang_t *compile_foreach(unlang_t *parent, unlang_compile_t *unlang_ctx, type = fr_table_value_by_str(fr_type_table, type_name, FR_TYPE_VOID); fr_assert(type != FR_TYPE_VOID); - if (type == FR_TYPE_NULL) type = da->type; + if (type == FR_TYPE_NULL) { + type = da->type; + + } else if (fr_type_is_leaf(type) != fr_type_is_leaf(da->type)) { + incompatible: + cf_log_err(cs, "Incompatible data types in foreach variable (%s), and reference being looped over (%s)", + fr_type_to_str(type), fr_type_to_str(da->type)); + goto fail; + + } else if (fr_type_is_structural(type) && (type != da->type)) { + goto incompatible; + } variable_name = cf_section_argv(cs, 1);