From ede63dd1ac1f0a46029d457304edcac2162bfab8 Mon Sep 17 00:00:00 2001 From: "Ying-Chun Liu (PaulLiu)" Date: Sun, 6 Aug 2023 05:24:02 +0800 Subject: [PATCH] tss2-tcti: tcti-libtpms: fix test failure on big-endian platform Due to tcti_libtpms->response_len and tcti_libtpms->response_buffer_len are size_t. We cannot convert the (size_t *) to (uint32_t *) on big-endian platforms. Thus we create temp uint32_t variables. Make the call and then assign it back to size_t variables. This commit partially fix the test failure on big-endian platforms. Signed-off-by: Ying-Chun Liu (PaulLiu) --- src/tss2-tcti/tcti-libtpms.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c index 3f026e396..cdc98b376 100644 --- a/src/tss2-tcti/tcti-libtpms.c +++ b/src/tss2-tcti/tcti-libtpms.c @@ -384,6 +384,8 @@ tcti_libtpms_transmit( tpm_header_t header; TSS2_RC rc; TPM_RESULT ret; + uint32_t resp_size; + uint32_t respbufsize; rc = tcti_common_transmit_checks(tcti_common, cmd_buf, TCTI_LIBTPMS_MAGIC); if (rc != TSS2_RC_SUCCESS) { @@ -400,11 +402,16 @@ tcti_libtpms_transmit( } LOGBLOB_DEBUG(cmd_buf, size, "Sending command with TPM_CC 0x%" PRIx32, header.size); + resp_size = (uint32_t) tcti_libtpms->response_len; + respbufsize = (uint32_t) tcti_libtpms->response_buffer_len; LIBTPMS_API_CALL(fail, tcti_libtpms, TPMLIB_Process, &tcti_libtpms->response_buffer, - (uint32_t *) &tcti_libtpms->response_len, - (uint32_t *) &tcti_libtpms->response_buffer_len, + (uint32_t *) &resp_size, + (uint32_t *) &respbufsize, (uint8_t *) cmd_buf, size); + tcti_libtpms->response_len = resp_size; + tcti_libtpms->response_buffer_len = respbufsize; + rc = tcti_libtpms_store_state(tcti_libtpms); if (rc != TSS2_RC_SUCCESS) { LOG_ERROR("Failed to store state file");