From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre AUBERT Date: Mon, 03 Mar 2014 18:14:16 +0100 Subject: [U-Boot] [PATCH 2/2] env export fix: compute the CRC on the real lenght of the exported variables. In-Reply-To: <20140226200247.GE16805@bill-the-cat> References: <1384434720-11214-1-git-send-email-p.aubert@staubli.com> <1384434720-11214-3-git-send-email-p.aubert@staubli.com> <20131114172423.A3845380C60@gemini.denx.de> <5285CB29.6030903@staubli.com> <20140226200247.GE16805@bill-the-cat> Message-ID: <5314B868.2000407@staubli.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Tom Rini Le 26/02/2014 21:02, Tom Rini a ?crit : > [ Catching up on some old emails ] > > On Fri, Nov 15, 2013 at 08:20:09AM +0100, Pierre AUBERT wrote: >> Dear Wolfgang Denk, >> >> Le 14/11/2013 18:24, Wolfgang Denk a ?crit : >>> Dear Pierre Aubert, >>> >>> In message <1384434720-11214-3-git-send-email-p.aubert@staubli.com> you wrote: >>>> Signed-off-by: Pierre Aubert >>>> --- >>>> common/cmd_nvedit.c | 5 +++-- >>>> 1 files changed, 3 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c >>>> index 5bcc324..c32a932 100644 >>>> --- a/common/cmd_nvedit.c >>>> +++ b/common/cmd_nvedit.c >>>> @@ -922,14 +922,15 @@ NXTARG: ; >>>> len = hexport_r(&env_htab, '\0', >>>> H_MATCH_KEY | H_MATCH_IDENT, >>>> - &res, ENV_SIZE, argc, argv); >>>> + &res, size, argc, argv); >>>> + >>>> if (len < 0) { >>>> error("Cannot export environment: errno = %d\n", errno); >>>> return 1; >>>> } >>>> if (chk) { >>>> - envp->crc = crc32(0, envp->data, ENV_SIZE); >>>> + envp->crc = crc32(0, envp->data, len); >>> This is not correct. When exporting with CRC, then the CRC >>> computation should be the same as is done with the persistently >>> stored environment, i. e. it should be taken over ENV_SIZE bytes. >> In this case, there's an inconstisency between the export and the >> import. It isn't possible to export some variables and the reimport >> them: >> U-Boot > env export -c >> U-Boot > env import -c fails with a CRC error. >> The import computes the CRC on the real lenght of the environment >> variables. IMO, as the import and the export are done to work >> together, it seems to me that the export should compute its CRC on >> the real lenght. > But env import -c $filesize does work as the export sets > filesize. > You're right, but my purpose wasn't to export and reimport immediatly the same environment. I thought it was more logical to have the same behaviour between "sister" functions. Best regards