/* Caution: This function may receive untrusted input. The data size is external input, so this function will validate it carefully to avoid buffer overflow. */
EFI_STATUS EFIAPI RuntimeServiceGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
/* Caution: This function may receive untrusted input. The data size is external input, so this function will validate it carefully to avoid buffer overflow. */
EFI_STATUS EFIAPI RuntimeServiceGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
{
  EFI_STATUS  Status;
  if ((VariableName == NULL) || (VendorGuid == NULL) || (DataSize == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  if (VariableName[0] == 0) {
    return EFI_NOT_FOUND;
  }
  AcquireLockOnlyAtBootTime (&mVariableServicesLock);
  if (FeaturePcdGet (PcdEnableVariableRuntimeCache)) {
    Status = FindVariableInRuntimeCache (VariableName, VendorGuid, Attributes, DataSize, Data);
  } else {
    Status = FindVariableInSmm (VariableName, VendorGuid, Attributes, DataSize, Data);
  }
  ReleaseLockOnlyAtBootTime (&mVariableServicesLock);
  return Status;
}