From dcbe69c09ca24e31268b6b9066156c7edd8873d1 Mon Sep 17 00:00:00 2001 From: Juergen Repp Date: Mon, 2 Dec 2024 20:33:43 +0100 Subject: [PATCH] tcti-msim: Fix call of socket_xmit_buf in send_sim_session_end. * socket_xmit_buf was not called after successful marshalling. * The result of the write function was not set in the wrapper function for write in the teardown function. Fixes: #2915 Signed-off-by: Juergen Repp --- src/tss2-tcti/tcti-mssim.c | 2 +- test/unit/tcti-mssim.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tss2-tcti/tcti-mssim.c b/src/tss2-tcti/tcti-mssim.c index a358452c6..5a83dbcbe 100644 --- a/src/tss2-tcti/tcti-mssim.c +++ b/src/tss2-tcti/tcti-mssim.c @@ -136,7 +136,7 @@ send_sim_session_end ( TSS2_RC rc; rc = Tss2_MU_UINT32_Marshal (TPM_SESSION_END, buf, sizeof (buf), NULL); - if (rc == TSS2_RC_SUCCESS) { + if (rc != TSS2_RC_SUCCESS) { return rc; } return socket_xmit_buf (sock, buf, sizeof (buf)); diff --git a/test/unit/tcti-mssim.c b/test/unit/tcti-mssim.c index c89149e7a..92d13d1eb 100644 --- a/test/unit/tcti-mssim.c +++ b/test/unit/tcti-mssim.c @@ -336,6 +336,9 @@ tcti_socket_teardown (void **state) { TSS2_TCTI_CONTEXT *ctx = (TSS2_TCTI_CONTEXT*)*state; + will_return (__wrap_write, 4); + will_return (__wrap_write, 4); + Tss2_Tcti_Finalize (ctx); free (ctx); return 0;