]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: env: Fix CRC calculation for 'env export -c -s'
authorNeil Stainton <nstainton@asl-control.co.uk>
Wed, 12 Sep 2018 11:02:51 +0000 (11:02 +0000)
committerTom Rini <trini@konsulko.com>
Sun, 30 Sep 2018 17:00:23 +0000 (13:00 -0400)
Fix failure to reimport exported checksummed, size constrained data block.

'env export -c' command ignores optional -s size argument when calculating checksum causing subsequent 'env import -c' to fail.

Signed-off-by: Neil Stainton <nstainton@asl-control.co.uk>
cmd/nvedit.c

index 793b68b88772f4c997553b31c76044943f5e1ff0..de16c72c23f2eab154265b9dbed54181645bf77a 100644 (file)
@@ -987,7 +987,8 @@ NXTARG:             ;
        }
 
        if (chk) {
-               envp->crc = crc32(0, envp->data, ENV_SIZE);
+               envp->crc = crc32(0, envp->data,
+                               size ? size - offsetof(env_t, data) : ENV_SIZE);
 #ifdef CONFIG_ENV_ADDR_REDUND
                envp->flags = ACTIVE_FLAG;
 #endif