Commit 018aca8d authored by Stefan Reinauer's avatar Stefan Reinauer Committed by Stefan Reinauer
Browse files

Only write the flash if the image has the same size


Corresponding to flashrom svn r76 and coreboot v2 svn r2503.
Signed-off-by: default avatarStefan Reinauer <stepan@coresystems.de>
Acked-by: default avatarSegher Boessenkool <segher@kernel.crashing.org>
parent 566820d7
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment