Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
check total_elements before using it.
Browse files Browse the repository at this point in the history
fix #172

Signed-off-by: Yang, Longlong <[email protected]>
  • Loading branch information
longlongyang authored and jyao1 committed Dec 12, 2023
1 parent 8afd6ce commit 72c6977
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spdmlib/src/common/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,11 @@ impl SpdmCodec for SecuredMessageDMTFVersionSelection {
) -> Option<SecuredMessageDMTFVersionSelection> {
let secured_message_general_opaque_data_header =
SecuredMessageGeneralOpaqueDataHeader::spdm_read(context, r)?;
if secured_message_general_opaque_data_header.total_elements as usize
> MAX_OPAQUE_LIST_ELEMENTS_COUNT
{
return None;
}
let mut opaque_element_dmtf_version_selection_list =
[OpaqueElementDMTFVersionSelection::default(); MAX_OPAQUE_LIST_ELEMENTS_COUNT];
for d in opaque_element_dmtf_version_selection_list
Expand Down

0 comments on commit 72c6977

Please sign in to comment.