[coreboot-gerrit] Patch set updated for coreboot: [DO NOT SUBMIT] cbfstool: deal with inconsistent use of master header fields

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Wed Oct 21 20:52:50 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11921

-gerrit

commit 9414ab9aae005f9eab3a47f92525effe40996395
Author: Patrick Georgi <pgeorgi at google.com>
Date:   Fri Oct 16 14:38:07 2015 +0200

    [DO NOT SUBMIT] cbfstool: deal with inconsistent use of master header fields
    
    The way we interpret offset and size of a cbfs in its master header is
    inconsistent. This fixes up things enough to make them work in the CrOS
    build system.
    
    Needed until the master header is deprecated (and even then we may want
    to find a compatible post-hoc specification for the benefit of the
    legacy master header support)
    
    Change-Id: I8878f09e346de4ca66488c1506cd1b5aaea813ec
    Signed-off-by: Patrick Georgi <pgeorgi at google.com>
---
 util/cbfstool/cbfs_image.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index bc5c5d7..10abeca 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -977,6 +977,18 @@ static int cbfs_header_valid(struct cbfs_header *header, size_t size)
 {
 	if ((ntohl(header->magic) == CBFS_HEADER_MAGIC) &&
 	    ((ntohl(header->version) == CBFS_HEADER_VERSION1) ||
+	     (ntohl(header->version) == CBFS_HEADER_VERSION2))) {
+	     if (ntohl(header->romsize) > size) {
+			DEBUG("romsize is %x, patching\n", ntohl(header->romsize));
+			DEBUG("offset is %x, patching\n", ntohl(header->offset));
+			header->romsize = htonl(size);
+			header->offset = htonl(0x40);
+			DEBUG("romsize is now %x\n", ntohl(header->romsize));
+			DEBUG("offset is now %x\n", ntohl(header->offset));
+		}
+	}
+	if ((ntohl(header->magic) == CBFS_HEADER_MAGIC) &&
+	    ((ntohl(header->version) == CBFS_HEADER_VERSION1) ||
 	     (ntohl(header->version) == CBFS_HEADER_VERSION2)) &&
 	    (ntohl(header->romsize) <= size) &&
 	    (ntohl(header->offset) < ntohl(header->romsize)))



More information about the coreboot-gerrit mailing list