Skip to content

Commit

Permalink
tcti-msim: Fix call of socket_xmit_buf in send_sim_session_end.
Browse files Browse the repository at this point in the history
* 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: tpm2-software#2915

Signed-off-by: Juergen Repp <juergen_repp@web.de>
  • Loading branch information
JuergenReppSIT committed Dec 2, 2024
1 parent d68270b commit 2ec4b24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tss2-tcti/tcti-mssim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions test/unit/tcti-mssim.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -358,6 +361,7 @@ tcti_mssim_get_poll_handles_test (void **state)
assert_int_equal (rc, TSS2_RC_SUCCESS);
assert_int_equal (num_handles, 1);
assert_int_equal (handles[0].fd, mssim_ctx->tpm_sock);

}
/*
*/
Expand Down

0 comments on commit 2ec4b24

Please sign in to comment.