Skip to content

Commit

Permalink
fix csr message format Fix:#2039
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaohanjlll <[email protected]>
  • Loading branch information
Xiaohanjlll authored and steven-bellock committed May 25, 2023
1 parent 884cf00 commit aac8583
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 6 additions & 6 deletions library/spdm_requester_lib/libspdm_req_get_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ static libspdm_return_t libspdm_try_get_csr(void *context,
spdm_request->opaque_data_length = opaque_data_length;
spdm_request->requester_info_length = requester_info_length;

if (opaque_data_length != 0) {
if (requester_info_length != 0) {
libspdm_copy_mem(spdm_request + 1,
spdm_request_size - sizeof(spdm_get_csr_request_t),
(uint8_t *)opaque_data, opaque_data_length);
(uint8_t *)requester_info, requester_info_length);
}

if (requester_info_length != 0) {
libspdm_copy_mem((uint8_t *)(spdm_request + 1) + opaque_data_length,
spdm_request_size - sizeof(spdm_get_csr_request_t),
(uint8_t *)requester_info, requester_info_length);
if (opaque_data_length != 0) {
libspdm_copy_mem((uint8_t *)(spdm_request + 1) + requester_info_length,
spdm_request_size - sizeof(spdm_get_csr_request_t) - requester_info_length,
(uint8_t *)opaque_data, opaque_data_length);
}

LIBSPDM_ASSERT(spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12);
Expand Down
5 changes: 1 addition & 4 deletions library/spdm_responder_lib/libspdm_rsp_csr.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ libspdm_return_t libspdm_get_response_csr(void *context, size_t request_size,
uint8_t *csr_p = csr_pointer;
uint16_t requester_info_length;
uint16_t opaque_data_length;
uint8_t *opaque_data;
uint8_t *requester_info;
bool need_reset;

Expand Down Expand Up @@ -103,9 +102,7 @@ libspdm_return_t libspdm_get_response_csr(void *context, size_t request_size,
response_size, response);
}

opaque_data = (void*)((size_t)(spdm_request + 1));

requester_info = (void*)(opaque_data + opaque_data_length);
requester_info = (void *)((size_t)(spdm_request + 1));

need_reset = libspdm_is_capabilities_flag_supported(
spdm_context, false, 0,
Expand Down

0 comments on commit aac8583

Please sign in to comment.