[U-Boot] [PATCH 2/2] env export fix: compute the CRC on the real lenght of the exported variables.

Wolfgang Denk wd at denx.de
Thu Nov 14 18:24:23 CET 2013


Dear Pierre Aubert,

In message <1384434720-11214-3-git-send-email-p.aubert at staubli.com> you wrote:
> Signed-off-by: Pierre Aubert <p.aubert at staubli.com>
> ---
>  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.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Hindsight is an exact science.


More information about the U-Boot mailing list