From 3b7590e6b10a8ed8ea7302e2e7616caef8964d94 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 5 Nov 2010 17:37:58 +0900 Subject: [PATCH] small bug fixes. --- ChangeLog | 4 ++++ src/ac.c | 2 +- src/flash.c | 4 ++-- src/openpgp-do.c | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 670daf1..17ffe5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-11-05 NIIBE Yutaka + Bug fixes. + * src/openpgp-do.c (gpg_do_write_prvkey): compare with != operator. + * src/ac.c (verify_admin_0): Don't hardcode 6, but use strlen. + * src/flash.c, src/gnuk.ld.in: Rename "Flash DO Pool" to "Flash Data Pool", because it's not only DO. * src/gnuk.h, src/opengpg-do.c: Cleanup. diff --git a/src/ac.c b/src/ac.c index 66ba242..3c018fd 100644 --- a/src/ac.c +++ b/src/ac.c @@ -195,7 +195,7 @@ verify_admin_0 (const uint8_t *pw, int buf_len, int pw_len_known) /* For empty PW3, pass phrase should be OPENPGP_CARD_INITIAL_PW3 */ { if ((pw_len_known >=0 && pw_len_known != strlen (OPENPGP_CARD_INITIAL_PW3)) - || buf_len < (int)strlen (OPENPGP_CARD_INITIAL_PW3) + || buf_len != (int)strlen (OPENPGP_CARD_INITIAL_PW3) || strncmp ((const char *)pw, OPENPGP_CARD_INITIAL_PW3, strlen (OPENPGP_CARD_INITIAL_PW3)) != 0) /* It is failure, but we don't try to lock for the case of empty PW3 */ diff --git a/src/flash.c b/src/flash.c index b75d1b3..7211ab4 100644 --- a/src/flash.c +++ b/src/flash.c @@ -211,7 +211,7 @@ flash_data_pool_allocate (size_t size) size = (size + 1) & ~1; /* allocation unit is 1-word (2-byte) */ if (last_p + size > data_pool - FLASH_DATA_POOL_HEADER_SIZE + FLASH_PAGE_SIZE) - return NULL; /* gc/erase/.../ */ + return NULL; /* XXX: here invoke gc/erase page/.../ */ last_p += size; return p; @@ -343,7 +343,7 @@ flash_key_write (uint8_t *key_addr, const uint8_t *key_data, void flash_key_release (const uint8_t *key_addr) { - (void)key_addr; + (void)key_addr; /* Not yet */ } void diff --git a/src/openpgp-do.c b/src/openpgp-do.c index 7764632..1a7a5db 100644 --- a/src/openpgp-do.c +++ b/src/openpgp-do.c @@ -698,7 +698,8 @@ gpg_do_write_prvkey (enum kind_of_key kk, const uint8_t *key_data, int key_len, uint8_t ks123_pw1[KEYSTRING_SIZE_PW1]; ks123_pw1[0] = strlen (OPENPGP_CARD_INITIAL_PW1); - sha1 ((uint8_t *)OPENPGP_CARD_INITIAL_PW1, 6, ks123_pw1+1); + sha1 ((uint8_t *)OPENPGP_CARD_INITIAL_PW1, + strlen (OPENPGP_CARD_INITIAL_PW1), ks123_pw1+1); encrypt (ks123_pw1+1, pd->dek_encrypted_1, DATA_ENCRYPTION_KEY_SIZE); }