summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2012-12-11 17:35:30 -0800
committerRonald G. Minnich <rminnich@gmail.com>2012-12-12 06:05:39 +0100
commitcf5aaaf1d25429fa6270c7d91a3e072dcf989079 (patch)
tree1ca61aa631c15e63bb5bf31f8319908788905dd0 /util
parent935a942e4abddb84e7e1ae60f8386a814d56db67 (diff)
downloadcoreboot-cf5aaaf1d25429fa6270c7d91a3e072dcf989079.tar.xz
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> Reviewed-on: http://review.coreboot.org/2028 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/cbfstool.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 10b29de113..6b520628f1 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);