diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2016-05-09 12:54:46 +0000 |
---|---|---|
committer | Luka Perkov <luka@openwrt.org> | 2016-06-19 19:56:13 +0200 |
commit | 79bd6bc9fb1532382fe38feb4b61323a568b9f23 (patch) | |
tree | 8388c3c21ca0cd4e44264f0f1f21c77b526ead54 | |
parent | 8ae10b6d327df1b74f78a2834128b53e2d7b38df (diff) | |
download | upstream-79bd6bc9fb1532382fe38feb4b61323a568b9f23.tar.gz upstream-79bd6bc9fb1532382fe38feb4b61323a568b9f23.tar.bz2 upstream-79bd6bc9fb1532382fe38feb4b61323a568b9f23.zip |
mtd: seama: update MD5 using header in the first block buffer
This will allow separating first block buffer from a buffer used for MD5
calculation.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Backport of r49307
git-svn-id: svn://svn.openwrt.org/openwrt/branches/chaos_calmer@49311 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | package/system/mtd/src/seama.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/package/system/mtd/src/seama.c b/package/system/mtd/src/seama.c index 42b1e88e08..b51177ac87 100644 --- a/package/system/mtd/src/seama.c +++ b/package/system/mtd/src/seama.c @@ -51,9 +51,8 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset); ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); int -seama_fix_md5(char *buf, size_t len) +seama_fix_md5(struct seama_entity_header *shdr, char *buf, size_t len) { - struct seama_entity_header *shdr = (struct seama_entity_header *) buf; char *data; size_t msize; size_t isize; @@ -163,7 +162,7 @@ mtd_fixseama(const char *mtd, size_t offset) exit(1); } - if (seama_fix_md5(buf, mtdsize)) + if (seama_fix_md5(shdr, buf, mtdsize)) goto out; if (mtd_erase_block(fd, block_offset)) { @@ -175,7 +174,7 @@ mtd_fixseama(const char *mtd, size_t offset) if (quiet < 2) fprintf(stderr, "Rewriting block at 0x%x\n", block_offset); - if (pwrite(fd, buf, erasesize, block_offset) != erasesize) { + if (pwrite(fd, first_block, erasesize, block_offset) != erasesize) { fprintf(stderr, "Error writing block (%s)\n", strerror(errno)); exit(1); } |