From 018aca8dcc85d696ccd8c036d1d63dca78e761a2 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Tue, 21 Nov 2006 23:48:51 +0000 Subject: Only write the flash if the image has the same size Corresponding to flashrom svn r76 and coreboot v2 svn r2503. Signed-off-by: Stefan Reinauer Acked-by: Segher Boessenkool --- flash_rom.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'flash_rom.c') diff --git a/flash_rom.c b/flash_rom.c index b9ef45e3..b1ca7b34 100644 --- a/flash_rom.c +++ b/flash_rom.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -332,10 +334,21 @@ int main(int argc, char *argv[]) fclose(image); printf("done\n"); } else { + struct stat image_stat; + if ((image = fopen(filename, "r")) == NULL) { perror(filename); exit(1); } + if (fstat(fileno(image), &image_stat) != 0) { + perror(filename); + exit(1); + } + if(image_stat.st_size!=flash->total_size*1024) { + perror("Image size doesnt match"); + exit(1); + } + fread(buf, sizeof(char), size, image); show_id(buf, size); fclose(image); -- cgit v1.2.3