aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/mtd/src/trx.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/system/mtd/src/trx.c')
-rw-r--r--package/system/mtd/src/trx.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c
index c1296a5f70..aaca232b6f 100644
--- a/package/system/mtd/src/trx.c
+++ b/package/system/mtd/src/trx.c
@@ -207,13 +207,6 @@ mtd_fixtrx(const char *mtd, size_t offset, size_t data_size)
exit(1);
}
- if (trx->len == STORE32_LE(data_size + TRX_CRC32_DATA_OFFSET)) {
- if (quiet < 2)
- fprintf(stderr, "Header already fixed, exiting\n");
- close(fd);
- return 0;
- }
-
buf = malloc(data_size);
if (!buf) {
perror("malloc");
@@ -243,6 +236,14 @@ mtd_fixtrx(const char *mtd, size_t offset, size_t data_size)
}
data_size = to - buf;
+ if (trx->len == STORE32_LE(data_size + TRX_CRC32_DATA_OFFSET) &&
+ trx->crc32 == STORE32_LE(crc32buf(buf, data_size))) {
+ if (quiet < 2)
+ fprintf(stderr, "Header already fixed, exiting\n");
+ close(fd);
+ return 0;
+ }
+
trx->len = STORE32_LE(data_size + offsetof(struct trx_header, flag_version));
trx->crc32 = STORE32_LE(crc32buf(buf, data_size));