From: Nick Porter Date: Thu, 31 Aug 2023 18:11:11 +0000 (+0100) Subject: Allow tmpl to be at the start of call_env destination structure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9902ca4f4b899d730300ecb173cb3bc850f85e9c;p=thirdparty%2Ffreeradius-server.git Allow tmpl to be at the start of call_env destination structure A tmpl at the start of the structure will have offset 0, so make the "no tmpl" offset -1. --- diff --git a/src/lib/unlang/call_env.c b/src/lib/unlang/call_env.c index d60c5c53b3b..7d7b335cb41 100644 --- a/src/lib/unlang/call_env.c +++ b/src/lib/unlang/call_env.c @@ -346,7 +346,7 @@ static unlang_action_t call_env_expand_repeat(UNUSED rlm_rcode_t *p_result, UNUS } tmpl_only: - if (env->rule->pair.tmpl_offset) tmpl_out = ((uint8_t *)*call_env_ctx->data) + env->rule->pair.tmpl_offset; + if (env->rule->pair.tmpl_offset >= 0) tmpl_out = ((uint8_t *)*call_env_ctx->data) + env->rule->pair.tmpl_offset; result = call_env_value_parse(*call_env_ctx->data, request, out, tmpl_out, env, &call_env_ctx->tmpl_expanded); if (result != CALL_ENV_SUCCESS) { diff --git a/src/lib/unlang/call_env.h b/src/lib/unlang/call_env.h index d4cfdeb7f1c..dce1d28df03 100644 --- a/src/lib/unlang/call_env.h +++ b/src/lib/unlang/call_env.h @@ -83,7 +83,7 @@ struct call_env_s { call_env_dest_t type; //!< Type of structure boxes will be written to. size_t size; //!< Size of structure boxes will be written to. char const *type_name; //!< Name of structure type boxes will be written to. - size_t tmpl_offset; //!< Where to write pointer to tmpl in the output structure. Optional. + ssize_t tmpl_offset; //!< Where to write pointer to tmpl in the output structure. Optional. } pair; struct { @@ -180,7 +180,8 @@ _Generic((((_s *)NULL)->_f), \ .nullable = _nullable, \ .type = FR_CALL_ENV_DST_TYPE(_struct, _field), \ .size = FR_CALL_ENV_DST_SIZE(_struct, _field), \ - .type_name = FR_CALL_ENV_DST_TYPE_NAME(_struct, _field) } + .type_name = FR_CALL_ENV_DST_TYPE_NAME(_struct, _field), \ + .tmpl_offset = -1 } /** Version of the above which sets optional field for pointer to tmpl */