Skip to content

Commit

Permalink
Rectify the four-byte alignment issue in the fuzzy testing.
Browse files Browse the repository at this point in the history
Signed-off-by: Xiao <[email protected]>
  • Loading branch information
Xiao authored and jyao1 committed May 10, 2024
1 parent ceb8802 commit 05f59eb
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
size_t libspdm_alignment_size(size_t size)
{
size_t alignment;
size_t max_buffer_size;

alignment = LIBSPDM_TEST_ALIGNMENT;
max_buffer_size = libspdm_get_max_buffer_size();

/* In the situation where max_buffer_size is not four-byte aligned, reserve sufficient size for the buffer_size */
if ((size > max_buffer_size - alignment) && (size & (alignment - 1)) != 0) {
size -= alignment;
}

if (((size) & (alignment - 1)) == 3) {
size += 1;
Expand Down

0 comments on commit 05f59eb

Please sign in to comment.