rom 0x6063c0 offset 0 ROM_PTR 0x7ffa30621000 fssize 458752
rom 0x6063c0 offset 458720 ROM_PTR 0x7ffa30690fe0 fssize 458752
Corrupt rom -- found no header at 458720

The problem is that the check to see if we're at the end is never reached.
I didn't look into it enough to know why fssize is 32 bytes larger than the
offset.  There may be another bug here.  Maybe something with the CBFS
header not being included or excluded from the calculation?

Anyway, this patch fixes it for all cases size > 32.  I'll review better
fixes :)  I also changed the error message so that it doesn't look like the
ROM is full just because it can't find room for a file.

Signed-off-by: Myles Watson <[email protected]>

Thanks,
Myles
Index: util/cbfstool/fs.c
===================================================================
--- util/cbfstool/fs.c	(revision 4369)
+++ util/cbfstool/fs.c	(working copy)
@@ -227,7 +227,7 @@
 	unsigned long nextoffset, truncoffset;
 	struct cbfs_file *newfile = NULL;
 
-	while (offset < rom->fssize) {
+	while ((offset + size) < rom->fssize) {
 
 		c = (struct cbfs_file *)ROM_PTR(rom, offset);
 
@@ -406,7 +406,7 @@
 		c = rom_alloc(rom, name, size, type);
 
 	if (c == NULL) {
-		ERROR("There is no more room in this ROM\n");
+		ERROR("There is not enough room in this ROM\n");
 		return -1;
 	}
 
-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to