Skip to content

Commit

Permalink
Fix EVENT_TYPES issues
Browse files Browse the repository at this point in the history
Fix #2641.
Fix #2642.
Fix #2643.

These fixes include a workaround for #2645 in https://github.com/DMTF/libspdm/blob/main/unit_test/test_spdm_requester/get_event_types.c. When that issue is fixed the workaround should be reverted.

Signed-off-by: Steven Bellock <[email protected]>
  • Loading branch information
steven-bellock committed Apr 3, 2024
1 parent 25cd9b5 commit e62ed10
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion library/spdm_requester_lib/libspdm_req_get_event_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static libspdm_return_t libspdm_try_get_event_types(libspdm_context_t *spdm_cont
spdm_request->header.request_response_code = SPDM_GET_SUPPORTED_EVENT_TYPES;
spdm_request->header.param1 = 0;
spdm_request->header.param2 = 0;
spdm_request_size = sizeof(spdm_heartbeat_request_t);
spdm_request_size = sizeof(spdm_get_supported_event_types_request_t);

/* -=[Send Request Phase]=- */
status = libspdm_send_spdm_request(spdm_context, &session_id, spdm_request_size, spdm_request);
Expand Down Expand Up @@ -118,13 +118,22 @@ static libspdm_return_t libspdm_try_get_event_types(libspdm_context_t *spdm_cont
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
goto receive_done;
}
if (spdm_response_size < sizeof(spdm_supported_event_types_response_t)) {
status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
goto receive_done;
}
if (spdm_response->supported_event_groups_list_len == 0) {
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
goto receive_done;
} else if (spdm_response->supported_event_groups_list_len > *supported_event_groups_list_len) {
status = LIBSPDM_STATUS_BUFFER_TOO_SMALL;
goto receive_done;
}
if (spdm_response_size != sizeof(spdm_supported_event_types_response_t) +
(uint64_t)spdm_response->supported_event_groups_list_len) {
status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
goto receive_done;
}

/* -=[Process Response Phase]=- */
*event_group_count = spdm_response->header.param1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ libspdm_return_t libspdm_get_response_supported_event_types(libspdm_context_t *s
spdm_request = request;

/* -=[Check Parameters Phase]=- */
LIBSPDM_ASSERT(spdm_request->header.request_response_code == SPDM_SUPPORTED_EVENT_TYPES);
LIBSPDM_ASSERT(spdm_request->header.request_response_code == SPDM_GET_SUPPORTED_EVENT_TYPES);

/* -=[Verify State Phase]=- */
if (spdm_context->response_state != LIBSPDM_RESPONSE_STATE_NORMAL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void libspdm_test_responder_supported_event_types_err_case1(void **state)
spdm_context->local_context.capability.flags &= ~SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EVENT_CAP;

spdm_request.header.spdm_version = SPDM_MESSAGE_VERSION_13;
spdm_request.header.request_response_code = SPDM_SUPPORTED_EVENT_TYPES;
spdm_request.header.request_response_code = SPDM_GET_SUPPORTED_EVENT_TYPES;
spdm_request.header.param1 = 0;
spdm_request.header.param2 = 0;

Expand Down
2 changes: 1 addition & 1 deletion unit_test/test_spdm_responder/supported_event_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void libspdm_test_responder_supported_event_types_case1(void **state)
set_standard_state(spdm_context);

spdm_request.header.spdm_version = SPDM_MESSAGE_VERSION_13;
spdm_request.header.request_response_code = SPDM_SUPPORTED_EVENT_TYPES;
spdm_request.header.request_response_code = SPDM_GET_SUPPORTED_EVENT_TYPES;
spdm_request.header.param1 = 0;
spdm_request.header.param2 = 0;

Expand Down

0 comments on commit e62ed10

Please sign in to comment.