Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fuzzy test case libspdm_test_responder_chunk_send_ack_case1 #2622

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,30 @@ void libspdm_test_responder_chunk_send_ack_case1(void **State)
chunk_num = 0;
bytes_sent = 0;
bytes_total = spdm_test_context->test_buffer_size;

/* All chunk send message sequences, including chunk_send_header and spdm_chunk. */
request = (uint8_t *)spdm_test_context->test_buffer;

do
{
if (chunk_num == 0) {
/* (uint32_t)LargeMessageSize , This field shall only be present when ChunkSeqNo
* is zero and shall have a non-zero value.
* The bytes_total should not be less than the minimum effective size.*/
if(bytes_total < sizeof(spdm_chunk_send_request_t) + sizeof(uint32_t)) {
break;
}
chunk_send_request = (spdm_chunk_send_request_t *)request;
spdm_message_header_t *test_spdm_message_header_t;

request_size = sizeof(spdm_chunk_send_request_t) + sizeof(uint32_t) +
chunk_send_request->chunk_size;

if (chunk_send_request->chunk_size > bytes_total) {
break;
}
if (chunk_send_request->chunk_size >
(request_size - sizeof(spdm_chunk_send_request_t) - sizeof(uint32_t)) ||
chunk_send_request->chunk_size == 0) {
/* Remaining space should meet the chunk_size. */
if(bytes_total - sizeof(spdm_chunk_send_request_t) - sizeof(uint32_t) <
chunk_send_request->chunk_size) {
break;
}

test_spdm_message_header_t =
(spdm_message_header_t *)(((uint8_t*) (chunk_send_request + 1)) + sizeof(uint32_t));
if (test_spdm_message_header_t->request_response_code == SPDM_RESPOND_IF_READY) {
Expand All @@ -113,17 +117,18 @@ void libspdm_test_responder_chunk_send_ack_case1(void **State)
chunk_send_request->chunk_size + sizeof(spdm_chunk_send_request_t) +
sizeof(uint32_t);
} else {
/* The remaining number of bytes should not be less than the minimum effective size*/
if(bytes_total - bytes_sent < sizeof(spdm_chunk_send_request_t)) {
break;
}
chunk_send_request = (spdm_chunk_send_request_t *)request;
spdm_message_header_t *test_spdm_message_header_t;

request_size = sizeof(spdm_chunk_send_request_t) + chunk_send_request->chunk_size;

if (chunk_send_request->chunk_size > bytes_total) {
break;
}
if (chunk_send_request->chunk_size >
(request_size - sizeof(spdm_chunk_send_request_t) - bytes_sent) ||
chunk_send_request->chunk_size == 0) {
/* Remaining space should meet the chunk_size. */
if(bytes_total - bytes_sent - sizeof(spdm_chunk_send_request_t) <
chunk_send_request->chunk_size) {
break;
}

Expand Down Expand Up @@ -155,7 +160,7 @@ void libspdm_test_responder_chunk_send_ack_case1(void **State)
if (status != LIBSPDM_STATUS_SUCCESS) {
break;
}
} while (bytes_sent < bytes_total);
}while (true);
}

libspdm_test_context_t m_libspdm_responder_chunk_send_ack_test_context = {
Expand Down
Loading