diff --git a/ChangeLog b/ChangeLog index cb67bec..aa8bc9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,17 @@ 2010-11-08 NIIBE Yutaka + * src/openpgp.c (cmd_change_password, cmd_reset_user_password): + Write to APDU correctly. + + * src/flash.c (flash_warning): Make it public. + * src/openpgp-do.c (do_hist_bytes, do_fp_all, do_cafp_all) (do_kgtime_all, do_ds_count): Fix return value. (rw_pw_status): Correctly return value. (proc_resetting_code): Change func proto. to return success/failure. (proc_key_import): Ditto. (gpg_do_put_data): Handle return values. + (gpg_do_write_simple): Don't write to APDU. 2010-11-05 NIIBE Yutaka diff --git a/src/flash.c b/src/flash.c index 7211ab4..4865ed2 100644 --- a/src/flash.c +++ b/src/flash.c @@ -260,7 +260,7 @@ flash_do_write (uint8_t nr, const uint8_t *data, int len) return p + 1; } -static void +void flash_warning (const char *msg) { (void)msg; diff --git a/src/gnuk.h b/src/gnuk.h index 12c20a7..95cbb5a 100644 --- a/src/gnuk.h +++ b/src/gnuk.h @@ -285,3 +285,4 @@ extern int flash_cnt123_get_value (const uint8_t *p); extern void flash_cnt123_increment (uint8_t which, const uint8_t **addr_p); extern void flash_cnt123_clear (const uint8_t **addr_p); extern void flash_put_data (uint16_t hw); +extern void flash_warning (const char *msg); diff --git a/src/openpgp-do.c b/src/openpgp-do.c index 7500854..30fcf82 100644 --- a/src/openpgp-do.c +++ b/src/openpgp-do.c @@ -1296,14 +1296,9 @@ gpg_do_write_simple (uint8_t nr, const uint8_t *data, int size) if (data != NULL) { *do_data_p = flash_do_write (nr, data, size); - if (*do_data_p) - GPG_SUCCESS (); - else - GPG_MEMORY_FAILURE (); + if (*do_data_p == NULL) + flash_warning ("DO WRITE ERROR"); } else - { - *do_data_p = NULL; - GPG_SUCCESS (); - } + *do_data_p = NULL; } diff --git a/src/openpgp.c b/src/openpgp.c index 3863d56..10f7572 100644 --- a/src/openpgp.c +++ b/src/openpgp.c @@ -260,6 +260,7 @@ cmd_change_password (void) ac_reset_pso_cds (); gpg_reset_pw_err_counter (PW_ERR_PW1); DEBUG_INFO ("Changed DO_KEYSTRING_PW1.\r\n"); + GPG_SUCCESS (); } else if (r > 0 && who == BY_USER) { @@ -267,6 +268,7 @@ cmd_change_password (void) ac_reset_pso_cds (); gpg_reset_pw_err_counter (PW_ERR_PW1); DEBUG_INFO ("Changed length of DO_KEYSTRING_PW1.\r\n"); + GPG_SUCCESS (); } else /* r >= 0 && who == BY_ADMIN */ { @@ -344,6 +346,7 @@ cmd_reset_user_password (void) ac_reset_pso_cds (); gpg_reset_pw_err_counter (PW_ERR_RC); gpg_reset_pw_err_counter (PW_ERR_PW1); + GPG_SUCCESS (); } else { @@ -386,6 +389,7 @@ cmd_reset_user_password (void) gpg_do_write_simple (NR_DO_KEYSTRING_PW1, new_ks0, KEYSTRING_SIZE_PW1); ac_reset_pso_cds (); gpg_reset_pw_err_counter (PW_ERR_PW1); + GPG_SUCCESS (); } else {