small bug fixes.

This commit is contained in:
NIIBE Yutaka
2010-11-05 17:37:58 +09:00
parent 7863290b62
commit 3b7590e6b1
4 changed files with 9 additions and 4 deletions

View File

@@ -1,5 +1,9 @@
2010-11-05 NIIBE Yutaka <gniibe@fsij.org> 2010-11-05 NIIBE Yutaka <gniibe@fsij.org>
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 * src/flash.c, src/gnuk.ld.in: Rename "Flash DO Pool" to "Flash
Data Pool", because it's not only DO. Data Pool", because it's not only DO.
* src/gnuk.h, src/opengpg-do.c: Cleanup. * src/gnuk.h, src/opengpg-do.c: Cleanup.

View File

@@ -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 */ /* For empty PW3, pass phrase should be OPENPGP_CARD_INITIAL_PW3 */
{ {
if ((pw_len_known >=0 && pw_len_known != strlen (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, || strncmp ((const char *)pw, OPENPGP_CARD_INITIAL_PW3,
strlen (OPENPGP_CARD_INITIAL_PW3)) != 0) strlen (OPENPGP_CARD_INITIAL_PW3)) != 0)
/* It is failure, but we don't try to lock for the case of empty PW3 */ /* It is failure, but we don't try to lock for the case of empty PW3 */

View File

@@ -211,7 +211,7 @@ flash_data_pool_allocate (size_t size)
size = (size + 1) & ~1; /* allocation unit is 1-word (2-byte) */ 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) 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; last_p += size;
return p; return p;
@@ -343,7 +343,7 @@ flash_key_write (uint8_t *key_addr, const uint8_t *key_data,
void void
flash_key_release (const uint8_t *key_addr) flash_key_release (const uint8_t *key_addr)
{ {
(void)key_addr; (void)key_addr; /* Not yet */
} }
void void

View File

@@ -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]; uint8_t ks123_pw1[KEYSTRING_SIZE_PW1];
ks123_pw1[0] = strlen (OPENPGP_CARD_INITIAL_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); encrypt (ks123_pw1+1, pd->dek_encrypted_1, DATA_ENCRYPTION_KEY_SIZE);
} }