firmware-utils/trx: fix two bugs
authorGabor Juhos <juhosg@openwrt.org>
Sat, 30 Nov 2013 18:30:56 +0000 (18:30 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 30 Nov 2013 18:30:56 +0000 (18:30 +0000)
 - fix crc32 calculation if -F was enabled.

 - don't convert the crc32 to little endian twice.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
SVN-Revision: 38962

src/trx.c

index 8e95d98d7ae64c6dd14598f34e46a8a9295b058e..e3b6a3941fc7d0ca4c70778d210b867e859b9690 100644 (file)
--- a/src/trx.c
+++ b/src/trx.c
@@ -273,11 +273,10 @@ int main(int argc, char **argv)
        }
 
        p->crc32 = crc32buf((char *) &p->flag_version,
-                                               (fsmark)?fsmark:cur_len - offsetof(struct trx_header, flag_version));
+                                               ((fsmark)?fsmark:cur_len) - offsetof(struct trx_header, flag_version));
        p->crc32 = STORE32_LE(p->crc32);
 
        p->len = STORE32_LE((fsmark) ? fsmark : cur_len);
-       p->len = STORE32_LE(p->len);
 
        /* restore TRXv2 bin-header */
        if (trx_version == 2) {