On 2017-11-17 17:32, Andreas J. Reichel wrote: > From: Andreas Reichel <andreas.reichel....@siemens.com> > > Only write environment if ustate differs from the value it is set to. > This reduces the risk of environment corruption. > > Add missing CRC calculation to enable resetting invalid configurations > without making those invalid, i.e. two configurations with both ustate > == INSTALLED can now be properly reset to ustate == OK, without > rendering the inactive config invalid. > > Signed-off-by: Andreas Reichel <andreas.reichel....@siemens.com> > --- > env/env_api.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/env/env_api.c b/env/env_api.c > index 29808ff..abfa49a 100644 > --- a/env/env_api.c > +++ b/env/env_api.c > @@ -188,10 +188,14 @@ int ebg_env_setglobalstate(ebgenv_t *e, uint16_t ustate) > if (!env) { > continue; > } > - env->data->ustate = ustate; > - if (!bgenv_write(env)) { > - (void)bgenv_close(env); > - return -EIO; > + if (env->data->ustate != ustate) { > + env->data->ustate = ustate; > + env->data->crc32 = crc32(0, (Bytef *)env->data, > + sizeof(BG_ENVDATA) - sizeof(env->data->crc32)); > + if (!bgenv_write(env)) { > + (void)bgenv_close(env); > + return -EIO; > + } > } > if (!bgenv_close(env)) { > return -EIO; >
Strictly spoken, this qualifies for two commits. Please do so in the future, I'm relaxing it in this case. Jan -- Siemens AG, Corporate Technology, CT RDA ITP SES-DE Corporate Competence Center Embedded Linux -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to efibootguard-dev+unsubscr...@googlegroups.com. To post to this group, send email to efibootguard-dev@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/10a0314b-10cb-4dc4-f061-15c8e9c291d8%40siemens.com. For more options, visit https://groups.google.com/d/optout.