From d71b029d1d178fb2e1cdb63ae5f45d10f90acca6 Mon Sep 17 00:00:00 2001 From: Neil Stainton Date: Wed, 12 Sep 2018 11:02:51 +0000 Subject: [PATCH] cmd: env: Fix CRC calculation for 'env export -c -s' 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 --- cmd/nvedit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 793b68b887..de16c72c23 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -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 -- 2.25.1