Skip to content

Commit 2f460a2

Browse files
FAPI: Fix segfault if Fapi_SetBranchCB is not called.
* An segfault did occur when PolicyOR is defined for an object but the callback for the branch selection was not set. * The current auth object, when policy authorize nv was executed, was not set. So a strange string was passed to the callback as object path of the object to be authorized. Signed-off-by: Juergen Repp <juergen_repp@web.de>
1 parent 5f682db commit 2f460a2

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/tss2-fapi/ifapi_policy_callbacks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,11 @@ ifapi_exec_auth_nv_policy(
15331533
if (fapi_ctx->policy.util_current_policy) {
15341534
/* Use the current policy in the policy stack. */
15351535
current_policy = fapi_ctx->policy.util_current_policy->pol_exec_ctx;
1536+
fapi_ctx->current_auth_object = fapi_ctx->policy.util_current_policy->pol_exec_ctx->auth_object;
15361537
} else {
15371538
/* Start with the bottom of the policy stack */
15381539
current_policy = fapi_ctx->policy.policyutil_stack->pol_exec_ctx;
1540+
fapi_ctx->current_auth_object = fapi_ctx->policy.policyutil_stack->pol_exec_ctx->auth_object;
15391541
}
15401542
cb_ctx = current_policy->app_data;
15411543
esys_ctx = fapi_ctx->esys;

src/tss2-fapi/ifapi_policyutil_execute.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ ifapi_policyutil_execute(FAPI_CONTEXT *context, ESYS_TR *session)
308308
}
309309
utl_ctx = utl_ctx->prev;
310310
}
311-
pol_util_ctx->pol_exec_ctx->session = ESYS_TR_NONE;
311+
if (pol_util_ctx->pol_exec_ctx) {
312+
pol_util_ctx->pol_exec_ctx->session = ESYS_TR_NONE;
313+
}
312314
}
313315
goto_if_error(r, "Execute policy.", error);
314316

0 commit comments

Comments
 (0)