From 2be6ae25b564a7cf1c50404cd293e452c5a8f4a5 Mon Sep 17 00:00:00 2001 From: Juergen Repp Date: Thu, 23 May 2024 11:40:14 +0200 Subject: [PATCH 2/8] tpm2_evictcontrol.c: Fix segfault for output of handle ESYS_TR_NONE If the -o parameter was used when a persistent handle should be evicted a segfault did occur. Now the object is evicted an a warning is displayed. Signed-off-by: Juergen Repp --- tools/tpm2_evictcontrol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/tpm2_evictcontrol.c b/tools/tpm2_evictcontrol.c index 8199be39..3fd7ee03 100644 --- a/tools/tpm2_evictcontrol.c +++ b/tools/tpm2_evictcontrol.c @@ -190,7 +190,11 @@ static tool_rc tpm2_tool_onrun(ESYS_CONTEXT *ectx, tpm2_option_flags flags) { tpm2_tool_output("action: %s\n", evicted ? "evicted" : "persisted"); tool_rc tmp_rc = tool_rc_success; if (ctx.output_arg) { - tmp_rc = files_save_ESYS_TR(ectx, out_tr, ctx.output_arg); + if (out_tr == ESYS_TR_NONE) { + LOG_WARN("The parameter --output can't be used if a persistent object will be evicted"); + } else { + tmp_rc = files_save_ESYS_TR(ectx, out_tr, ctx.output_arg); + } } if (!evicted) { -- 2.49.0