// Synchronous SMI for SMM Core or request from Communicate protocol\r
//\r
CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)gSmmCorePrivate->CommunicationBuffer;\r
- *gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
+ gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
Status = SmiManage (\r
&CommunicateHeader->HeaderGuid, \r
NULL, \r
CommunicateHeader->Data, \r
- gSmmCorePrivate->BufferSize\r
+ &gSmmCorePrivate->BufferSize\r
);\r
\r
//\r
// Update CommunicationBuffer, BufferSize and ReturnStatus\r
// Communicate service finished, reset the pointer to CommBuffer to NULL\r
//\r
- *gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
+ gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
gSmmCorePrivate->CommunicationBuffer = NULL;\r
gSmmCorePrivate->ReturnStatus = (Status == EFI_WARN_INTERRUPT_SOURCE_QUIESCED) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
} else {\r
/// in bytes, into a software SMI handler and for the software SMI handler to pass the \r
/// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.\r
///\r
- UINTN *BufferSize;\r
+ UINTN BufferSize;\r
\r
///\r
/// This field is used by the SMM Communication Protocol to pass the return status from\r
FALSE, // SmmEntryPointRegistered\r
FALSE, // InSmm\r
NULL, // Smst\r
- 0, // BufferSize\r
NULL, // CommunicationBuffer\r
+ 0, // BufferSize\r
EFI_SUCCESS // ReturnStatus\r
};\r
\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ //\r
+ // CommSize must hold HeaderGuid and MessageLength\r
+ //\r
+ if (*CommSize < OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
//\r
// If not already in SMM, then generate a Software SMI\r
//\r
// Put arguments for Software SMI in gSmmCorePrivate\r
//\r
gSmmCorePrivate->CommunicationBuffer = CommBuffer;\r
- gSmmCorePrivate->BufferSize = CommSize;\r
+ gSmmCorePrivate->BufferSize = *CommSize;\r
\r
//\r
// Generate Software SMI\r
//\r
// Return status from software SMI \r
//\r
+ *CommSize = gSmmCorePrivate->BufferSize;\r
return gSmmCorePrivate->ReturnStatus;\r
}\r
\r