From 864fae2d78f88a1ec3865c6eeffa9eb605cc6b38 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Fri, 6 Feb 2015 15:35:34 -0800 Subject: Check the correct length of the GPT header signature The length of the signature is 8 bytes. We've been checking 9 bytes instead, pretty much forever. All the tests have passed because although the signature we're looking for is an 8-byte string followed by a '\0', the next field in the header contains the revision number 0x00010000, so the 9th byte is always zero. We should follow the spec, though. BUG=none BRANCH=none TEST=make runtests Change-Id: I7cc6370250fa36a193f4a9fa5bc0099aea465618 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/247331 Reviewed-by: Randall Spangler --- firmware/include/gpt.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/firmware/include/gpt.h b/firmware/include/gpt.h index fa537397..15918a70 100644 --- a/firmware/include/gpt.h +++ b/firmware/include/gpt.h @@ -2,19 +2,22 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * - * Defines EFI related structure. See more details in EFI 2.3 spec. + * Defines UEFI related structure. See more details in the UEFI spec. * - * To download EFI standard, please visit UEFI homepage: + * To download UEFI standard, please visit UEFI homepage: * http://www.uefi.org/ */ #ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_ #define VBOOT_REFERENCE_CGPTLIB_GPT_H_ #include +/* From the specification */ +#define GPT_HEADER_SIGNATURE_SIZE 8 +#define GPT_HEADER_REVISION 0x00010000 #define GPT_HEADER_SIGNATURE "EFI PART" + +/* From https://chromium-review.googlesource.com/31264 */ #define GPT_HEADER_SIGNATURE2 "CHROMEOS" -#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE) -#define GPT_HEADER_REVISION 0x00010000 /* * The first 3 numbers should be stored in network-endian format according to @@ -43,7 +46,7 @@ #define UUID_NODE_LEN 6 #define GUID_SIZE 16 -/* GUID definition. Defined in appendix A of EFI standard. */ +/* GUID definition. Defined in appendix A of UEFI standard. */ typedef struct { union { struct { @@ -63,12 +66,12 @@ typedef struct { /* * GPT header defines how many partitions exist on a drive and sectors managed. * For every drive device, there are 2 headers, primary and secondary. Most of - * fields are duplicated except my_lba and entries_lba. + * the fields are duplicates except my_lba and entries_lba. * - * You may find more details in chapter 5 of EFI standard. + * You may find more details in chapter 5 of the UEFI standard. */ typedef struct { - char signature[8]; + char signature[GPT_HEADER_SIGNATURE_SIZE]; uint32_t revision; uint32_t size; uint32_t header_crc32; @@ -91,7 +94,7 @@ typedef struct { * GPT partition entry defines the starting and ending LBAs of a partition. It * also contains the unique GUID, type, and attribute bits. * - * You may find more details in chapter 5 of EFI standard. + * You may find more details in chapter 5 of the UEFI standard. */ typedef struct { Guid type; -- cgit v1.2.1