PartitionValidGptTable(), PartitionCheckGptEntry() routine will accept disk\r
partition content and validate the GPT table and GPT entry.\r
\r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
@param[in] This Calling context.\r
@param[in] Handle Parent Handle.\r
@param[in] DiskIo Parent DiskIo interface.\r
+ @param[in] DiskIo2 Parent DiskIo2 interface.\r
@param[in] BlockIo Parent BlockIo interface.\r
@param[in] BlockIo2 Parent BlockIo2 interface.\r
@param[in] DevicePath Parent Device Path.\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Handle,\r
IN EFI_DISK_IO_PROTOCOL *DiskIo,\r
+ IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo,\r
IN EFI_BLOCK_IO2_PROTOCOL *BlockIo2,\r
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
DEBUG ((EFI_D_INFO, " Valid primary and !Valid backup partition table\n"));\r
DEBUG ((EFI_D_INFO, " Restore backup partition table by the primary\n"));\r
if (!PartitionRestoreGptTable (BlockIo, DiskIo, PrimaryHeader)) {\r
- DEBUG ((EFI_D_INFO, " Restore backup partition table error\n"));\r
+ DEBUG ((EFI_D_INFO, " Restore backup partition table error\n"));\r
}\r
\r
if (PartitionValidGptTable (BlockIo, DiskIo, PrimaryHeader->AlternateLBA, BackupHeader)) {\r
This,\r
Handle,\r
DiskIo,\r
+ DiskIo2,\r
BlockIo,\r
BlockIo2,\r
DevicePath,\r
\r
if ((PartHdr->Header.Signature != EFI_PTAB_HEADER_ID) ||\r
!PartitionCheckCrc (BlockSize, &PartHdr->Header) ||\r
- PartHdr->MyLBA != Lba\r
+ PartHdr->MyLBA != Lba ||\r
+ (PartHdr->SizeOfPartitionEntry < sizeof (EFI_PARTITION_ENTRY))\r
) {\r
DEBUG ((EFI_D_INFO, "Invalid efi partition table header\n"));\r
FreePool (PartHdr);\r
return FALSE;\r
}\r
\r
+ //\r
+ // Ensure the NumberOfPartitionEntries * SizeOfPartitionEntry doesn't overflow.\r
+ //\r
+ if (PartHdr->NumberOfPartitionEntries > DivU64x32 (MAX_UINTN, PartHdr->SizeOfPartitionEntry)) {\r
+ FreePool (PartHdr);\r
+ return FALSE;\r
+ }\r
+\r
CopyMem (PartHeader, PartHdr, sizeof (EFI_PARTITION_TABLE_HEADER));\r
if (!PartitionCheckGptEntryArrayCRC (BlockIo, DiskIo, PartHeader)) {\r
FreePool (PartHdr);\r