From 628c03634b06b0000d06bd4b42ca75525b48b91d Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 3 Jul 2012 18:36:24 +0900 Subject: [PATCH] Bug fix against flash GC --- src/gnuk.h | 2 +- src/openpgp-do.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gnuk.h b/src/gnuk.h index 4c2fb3b..b539159 100644 --- a/src/gnuk.h +++ b/src/gnuk.h @@ -306,7 +306,7 @@ extern uint8_t admin_authorized; /* * Representation of Boolean object: * 0: No record in flash memory - * 1: 0xc?00 + * 1: 0xf000 */ #define NR_BOOL_PW1_LIFETIME 0xf0 /* diff --git a/src/openpgp-do.c b/src/openpgp-do.c index 4299048..f75a2c6 100644 --- a/src/openpgp-do.c +++ b/src/openpgp-do.c @@ -877,6 +877,7 @@ gpg_do_chks_prvkey (enum kind_of_key kk, dek_p += DATA_ENCRYPTION_KEY_SIZE * (who_new - who_old); memcpy (dek_p, dek, DATA_ENCRYPTION_KEY_SIZE); + do_ptr[nr - NR_DO__FIRST__] = NULL; p = flash_do_write (nr, (const uint8_t *)pd, sizeof (struct prvkey_data)); do_ptr[nr - NR_DO__FIRST__] = p; @@ -1398,6 +1399,7 @@ gpg_do_put_data (uint16_t tag, const uint8_t *data, int len) GPG_MEMORY_FAILURE (); else { + *do_data_p = NULL; *do_data_p = flash_do_write (nr, data, len); if (*do_data_p) GPG_SUCCESS (); @@ -1512,6 +1514,7 @@ gpg_do_write_simple (uint8_t nr, const uint8_t *data, int size) if (data != NULL) { + *do_data_p = NULL; *do_data_p = flash_do_write (nr, data, size); if (*do_data_p == NULL) flash_warning ("DO WRITE ERROR");