Skip to content
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
6 changes: 5 additions & 1 deletion src/migtd/src/spdm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ impl<T: AsyncRead + AsyncWrite + Unpin> SpdmDeviceIo for MigtdTransport<T> {
_timeout: usize,
) -> Result<usize, usize> {
let mut buffer = buffer.lock();
if buffer.len() < VMCALL_SPDM_MESSAGE_HEADER_SIZE {
return Err(0_usize);
}

let mut recvd = 0;
while recvd < VMCALL_SPDM_MESSAGE_HEADER_SIZE {
let n = self
Expand All @@ -78,7 +82,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin> SpdmDeviceIo for MigtdTransport<T> {
vmcall_msg::VmCallMessageHeader::read(&mut reader).ok_or(0_usize)?;
let payload_size = vmcall_msg_header.length as usize;

if buffer.len() < payload_size + VMCALL_SPDM_MESSAGE_HEADER_SIZE {
if payload_size > buffer.len().saturating_sub(VMCALL_SPDM_MESSAGE_HEADER_SIZE) {
return Err(0_usize);
}

Expand Down
Loading