Stefan Reinauer (stefan.reinauer@coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2028
-gerrit
commit 2fdb9fa8e7249c6d0e006a78d062023d42a591e6 Author: Stefan Reinauer reinauer@chromium.org Date: Tue Dec 11 17:35:30 2012 -0800
cbfstool: Catch failing parse_elf_to_payload()
Otherwise cbfstool will segfault if you try to add an x86 payload to an ARM image.
Change-Id: Ie468005ce9325a4f17c4f206c59f48e39d9338df Signed-off-by: Stefan Reinauer reinauer@google.com --- util/cbfstool/cbfstool.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 10b29de..6b52062 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -106,7 +106,7 @@ static int cbfs_add(void)
static int cbfs_add_payload(void) { - uint32_t filesize = 0; + int32_t filesize = 0; void *rom, *filedata, *cbfsfile; unsigned char *payload;
@@ -136,6 +136,12 @@ static int cbfs_add_payload(void) }
filesize = parse_elf_to_payload(filedata, &payload, rom_algo); + if (filesize <= 0) { + fprintf(stderr, "E: Adding payload '%s' failed.\n", + rom_filename); + free(rom); + return 1; + }
cbfsfile = create_cbfs_file(rom_name, payload, &filesize, CBFS_COMPONENT_PAYLOAD, &rom_baseaddress);