summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2006-11-21 23:48:51 +0000
committerStefan Reinauer <stepan@openbios.org>2006-11-21 23:48:51 +0000
commit3a998642f553b5f280319ae9eddc66b19c3c8b89 (patch)
tree71740f484f1ec3b6c91e892fdff1465479eec51c /util
parent9e2019200f2316d5997e7593e7f4bae08c560541 (diff)
downloadcoreboot-3a998642f553b5f280319ae9eddc66b19c3c8b89.tar.xz
flashrom: Only write the flash if the image has the same size
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Segher Boessenkool <segher@kernel.crashing.org> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2503 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r--util/flashrom/flash_rom.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/util/flashrom/flash_rom.c b/util/flashrom/flash_rom.c
index b9ef45e37d..b1ca7b3466 100644
--- a/util/flashrom/flash_rom.c
+++ b/util/flashrom/flash_rom.c
@@ -28,6 +28,8 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
@@ -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);