Skip to content

Commit 7f4c0be

Browse files
More descriptive buffer error codes
Fix #2223. Signed-off-by: Steven Bellock <[email protected]>
1 parent 30014a8 commit 7f4c0be

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

library/spdm_requester_lib/libspdm_req_send_receive.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,20 @@ libspdm_return_t libspdm_send_spdm_request(libspdm_context_t *spdm_context,
562562
size_t msg_log_size;
563563
#endif /* LIBSPDM_ENABLE_MSG_LOG */
564564

565-
/* large SPDM message is the SPDM message whose size is greater than the DataTransferSize of the receiving
566-
* SPDM endpoint or greater than the transmit buffer size of the sending SPDM endpoint */
567-
if (((spdm_context->connection_info.capability.data_transfer_size != 0 &&
568-
request_size > spdm_context->connection_info.capability.data_transfer_size) ||
569-
(spdm_context->local_context.capability.sender_data_transfer_size != 0 &&
570-
request_size > spdm_context->local_context.capability.sender_data_transfer_size)) &&
571-
!libspdm_is_capabilities_flag_supported(
565+
/* If chunking is not supported then message must fit in both the send buffer and the receive
566+
* buffer. */
567+
if (!libspdm_is_capabilities_flag_supported(
572568
spdm_context, true,
573569
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP,
574570
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP)) {
575-
return LIBSPDM_STATUS_SEND_FAIL;
571+
if ((spdm_context->connection_info.capability.data_transfer_size != 0) &&
572+
(request_size > spdm_context->connection_info.capability.data_transfer_size)) {
573+
return LIBSPDM_STATUS_PEER_BUFFER_TOO_SMALL;
574+
}
575+
if ((spdm_context->local_context.capability.sender_data_transfer_size != 0) &&
576+
(request_size > spdm_context->local_context.capability.sender_data_transfer_size)) {
577+
return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
578+
}
576579
}
577580

578581
if ((session_id != NULL) &&

0 commit comments

Comments
 (0)