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

Commit

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

Signed-off-by: Yang, Longlong <[email protected]>
  • Loading branch information
longlongyang authored and jyao1 committed Dec 12, 2023
1 parent 45e459e commit 8afd6ce
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spdmlib/src/common/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ impl SpdmCodec for SecuredMessageVersionList {
}
fn spdm_read(context: &mut SpdmContext, r: &mut Reader) -> Option<SecuredMessageVersionList> {
let version_count = u8::read(r)?;
if version_count as usize > MAX_SECURE_SPDM_VERSION_COUNT {
return None;
}
let mut versions_list = [SecuredMessageVersion::default(); MAX_SECURE_SPDM_VERSION_COUNT];
for d in versions_list.iter_mut().take(version_count as usize) {
*d = SecuredMessageVersion::spdm_read(context, r)?;
Expand Down

0 comments on commit 8afd6ce

Please sign in to comment.