Skip to content

Commit

Permalink
Check LargeResponse error
Browse files Browse the repository at this point in the history
Fix DMTF#1207.

Signed-off-by: Steven Bellock <sbellock@nvidia.com>
  • Loading branch information
steven-bellock committed Jul 18, 2023
1 parent 1467b2d commit 461e344
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions library/spdm_requester_lib/libspdm_req_send_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,27 @@ libspdm_return_t libspdm_receive_spdm_response(libspdm_context_t *spdm_context,

if (spdm_response->request_response_code == SPDM_ERROR
&& spdm_response->param1 == SPDM_ERROR_CODE_LARGE_RESPONSE) {
spdm_message_header_t *request_message;

request_message = (spdm_message_header_t *)spdm_context->last_spdm_request;

switch (request_message->request_response_code)
{
case SPDM_GET_VERSION:
case SPDM_GET_CAPABILITIES:
case SPDM_PSK_FINISH:
case SPDM_HEARTBEAT:
case SPDM_KEY_UPDATE:
case SPDM_END_SESSION:
case SPDM_SET_CERTIFICATE:
/* The responses to these requests cannot be chunked as they are smaller than the
* MinDataTransferSize. */
status = LIBSPDM_STATUS_ERROR_PEER;
goto receive_done;
default:
break;
}

status = libspdm_handle_error_large_response(
spdm_context, session_id,
response_size, (void*) spdm_response, response_capacity);
Expand All @@ -746,15 +767,6 @@ libspdm_return_t libspdm_receive_spdm_response(libspdm_context_t *spdm_context,
status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
goto receive_done;
}

/* Per the spec, SPDM_VERSION and SPDM_CAPABILITIES shall not be chunked
* and should be an unexpected error. */
if (spdm_response->request_response_code == SPDM_VERSION ||
spdm_response->request_response_code == SPDM_CAPABILITIES
) {
status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
goto receive_done;
}
}

receive_done:
Expand Down

0 comments on commit 461e344

Please sign in to comment.