/* Validate the Boot####, Driver####, SysPrep#### and PlatformRecovery#### variable (VendorGuid/Name) */
BOOLEAN BmValidateOption(UINT8 *Variable, UINTN VariableSize)
/* Validate the Boot####, Driver####, SysPrep#### and PlatformRecovery#### variable (VendorGuid/Name) */
BOOLEAN BmValidateOption(UINT8 *Variable, UINTN VariableSize)
{
  UINT16                    FilePathSize;
  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
  UINTN                     DescriptionSize;
  if (VariableSize <= sizeof (UINT16) + sizeof (UINT32)) {
    return FALSE;
  }
  Variable += sizeof (UINT32);
  FilePathSize = ReadUnaligned16 ((UINT16 *)Variable);
  Variable    += sizeof (UINT16);
  DescriptionSize = BmStrSizeEx ((CHAR16 *)Variable, VariableSize - sizeof (UINT16) - sizeof (UINT32));
  Variable       += DescriptionSize;
  DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Variable;
  if ((FilePathSize == 0) || (DescriptionSize == 0)) {
    return FALSE;
  }
  if (sizeof (UINT32) + sizeof (UINT16) + DescriptionSize + FilePathSize > VariableSize) {
    return FALSE;
  }
  return (BOOLEAN)(BmGetDevicePathSizeEx (DevicePath, FilePathSize) != 0);
}