diff options
author | Michal Suchanek <hramrach@gmail.com> | 2013-06-24 18:20:51 +0400 |
---|---|---|
committer | Henrik Nordstrom <henrik@henriknordstrom.net> | 2013-06-25 01:06:14 +0400 |
commit | c66667ff5276101f9ec1d9e77093af3ae1f5015c (patch) | |
tree | b5d4f045b102cb633183ecd1cb7eaccecd517721 /nand-part.c | |
parent | f1eca9d438a6a54bf31fa60c09d968d02857f75f (diff) |
nand-part: Reject wrong partition version.
Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
Diffstat (limited to 'nand-part.c')
-rw-r--r-- | nand-part.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/nand-part.c b/nand-part.c index dde5e01..3bd5138 100644 --- a/nand-part.c +++ b/nand-part.c @@ -49,6 +49,7 @@ #include <string.h> #include <errno.h> #include <fcntl.h> +#include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> /* BLKRRPART */ #include "nand-part.h" @@ -96,6 +97,8 @@ __u32 calc_crc32(void * buffer, __u32 length) MBR *_get_mbr(int fd, int mbr_num) { MBR *mbr; + const char * magic = "softw311"; + unsigned version = 0x100; /*request mbr space*/ mbr = malloc(sizeof(MBR)); @@ -112,6 +115,16 @@ MBR *_get_mbr(int fd, int mbr_num) /*checksum*/ printf("check partition table copy %d: ", mbr_num); printmbrheader(mbr); + if(strncmp((char *)mbr->magic, magic, 8)) + { + printf("magic %8.8s is not %8s\n", mbr->magic, magic); + return NULL; + } + if(mbr->version != version) + { + printf("version 0x%08x is not 0x%08x\n", mbr->version, version); + return NULL; + } if(*(__u32 *)mbr == calc_crc32((__u32 *)mbr + 1,MBR_SIZE - 4)) { printf("OK\n"); |