Author: oxygene Date: 2009-09-15 10:21:46 +0200 (Tue, 15 Sep 2009) New Revision: 4634
Modified: trunk/coreboot-v2/util/cbfstool/cbfstool.c trunk/coreboot-v2/util/cbfstool/common.c Log: More error checking when trying to open files in cbfstool. (trivial)
Signed-off-by: Patrick Georgi patrick.georgi@coresystems.de Acked-by: Patrick Georgi patrick.georgi@coresystems.de
Modified: trunk/coreboot-v2/util/cbfstool/cbfstool.c =================================================================== --- trunk/coreboot-v2/util/cbfstool/cbfstool.c 2009-09-14 17:00:04 UTC (rev 4633) +++ trunk/coreboot-v2/util/cbfstool/cbfstool.c 2009-09-15 08:21:46 UTC (rev 4634) @@ -57,6 +57,10 @@ }
void *rom = loadrom(romname); + if (rom == NULL) { + printf("Could not load ROM image '%s'.\n", romname); + return 1; + }
if (strcmp(cmd, "print") == 0) { print_cbfs_directory(romname); @@ -68,11 +72,15 @@ return 1; }
- void *filename = argv[3]; - void *cbfsname = argv[4]; + char *filename = argv[3]; + char *cbfsname = argv[4];
uint32_t filesize = 0; void *filedata = loadfile(filename, &filesize, 0, SEEK_SET); + if (filedata == NULL) { + printf("Could not load file '%s'.\n", filename); + return 1; + }
uint32_t base = 0; void *cbfsfile;
Modified: trunk/coreboot-v2/util/cbfstool/common.c =================================================================== --- trunk/coreboot-v2/util/cbfstool/common.c 2009-09-14 17:00:04 UTC (rev 4633) +++ trunk/coreboot-v2/util/cbfstool/common.c 2009-09-15 08:21:46 UTC (rev 4634) @@ -31,6 +31,8 @@ int place) { FILE *file = fopen(filename, "rb"); + if (file == NULL) + return NULL; fseek(file, 0, SEEK_END); *romsize_p = ftell(file); fseek(file, 0, SEEK_SET); @@ -65,6 +67,8 @@ void *loadrom(const char *filename) { void *romarea = loadfile(filename, &romsize, 0, SEEK_SET); + if (romarea == NULL) + return NULL; recalculate_rom_geometry(romarea); return romarea; }