]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow tmpl to be at the start of call_env destination structure
authorNick Porter <nick@portercomputing.co.uk>
Thu, 31 Aug 2023 18:11:11 +0000 (19:11 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 1 Sep 2023 09:39:08 +0000 (10:39 +0100)
A tmpl at the start of the structure will have offset 0, so make the "no
tmpl" offset -1.

src/lib/unlang/call_env.c
src/lib/unlang/call_env.h

index d60c5c53b3b3ef06a123e2a4daa38cbf157e3820..7d7b335cb41fc6b40dd0946997d44e1cd8466a89 100644 (file)
@@ -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) {
index d4cfdeb7f1cd691726fdd4a927091c485976cd89..dce1d28df03c3d77445e760064063a5e792cab5d 100644 (file)
@@ -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
  */