File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ impl<T: AsyncRead + AsyncWrite + Unpin> SpdmDeviceIo for MigtdTransport<T> {
6363 _timeout : usize ,
6464 ) -> Result < usize , usize > {
6565 let mut buffer = buffer. lock ( ) ;
66+ if buffer. len ( ) < VMCALL_SPDM_MESSAGE_HEADER_SIZE {
67+ return Err ( 0_usize ) ;
68+ }
69+
6670 let mut recvd = 0 ;
6771 while recvd < VMCALL_SPDM_MESSAGE_HEADER_SIZE {
6872 let n = self
@@ -78,7 +82,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin> SpdmDeviceIo for MigtdTransport<T> {
7882 vmcall_msg:: VmCallMessageHeader :: read ( & mut reader) . ok_or ( 0_usize ) ?;
7983 let payload_size = vmcall_msg_header. length as usize ;
8084
81- if buffer. len ( ) < payload_size + VMCALL_SPDM_MESSAGE_HEADER_SIZE {
85+ if payload_size > buffer. len ( ) . saturating_sub ( VMCALL_SPDM_MESSAGE_HEADER_SIZE ) {
8286 return Err ( 0_usize ) ;
8387 }
8488
You can’t perform that action at this time.
0 commit comments