public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 1/4] disk: part_efi: range-check partition number
@ 2012-09-05 22:03 Stephen Warren
  2012-09-05 22:03 ` [U-Boot] [PATCH V2 2/4] disk: part_efi: parse and store partition UUID Stephen Warren
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Stephen Warren @ 2012-09-05 22:03 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Enhance get_partition_info_efi() to range-check the partition number.
This prevents invalid partitions being accessed, and prevents access
beyond the end of the gpt_pte[] array.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v2: New patch
---
 disk/part_efi.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 02927a0..2962fd8 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -173,6 +173,13 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 		return -1;
 	}
 
+	if (part > le32_to_int(gpt_head->num_partition_entries) ||
+	    !is_pte_valid(&gpt_pte[part - 1])) {
+		printf("%s: *** ERROR: Invalid partition number %d ***\n",
+			__func__, part);
+		return -1;
+	}
+
 	/* The ulong casting limits the maximum disk size to 2 TB */
 	info->start = (ulong) le64_to_int(gpt_pte[part - 1].starting_lba);
 	/* The ending LBA is inclusive, to calculate size, add 1 to it */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-09-12 16:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 22:03 [U-Boot] [PATCH V2 1/4] disk: part_efi: range-check partition number Stephen Warren
2012-09-05 22:03 ` [U-Boot] [PATCH V2 2/4] disk: part_efi: parse and store partition UUID Stephen Warren
2012-09-05 23:24   ` Tom Rini
2012-09-05 22:03 ` [U-Boot] [PATCH V2 3/4] disk: part_msdos: " Stephen Warren
2012-09-05 22:03 ` [U-Boot] [PATCH V2 4/4] cmd_part: add partition-related command Stephen Warren
2012-09-05 23:51   ` Rob Herring
2012-09-05 23:58     ` Tom Rini
2012-09-07 19:42       ` Stephen Warren
2012-09-11 22:52       ` Stephen Warren
2012-09-12  7:00         ` Lukasz Majewski
2012-09-12 16:48           ` Tom Rini
2012-09-12 16:47         ` Tom Rini
2012-09-06  2:38     ` Stephen Warren
2012-09-06 17:12       ` Tom Rini
2012-09-06 18:46         ` Stephen Warren
2012-09-06 22:45           ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox