[coreboot-gerrit] New patch to review for coreboot: [DO NOT SUBMIT] cbfstool: deal with inconsistent use of master header fields

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Fri Oct 16 14:39:58 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 89aaa4ebe75e35f547e714cbff79e36a1319efff
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 895927d..78c0c2e 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -973,6 +973,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