fixed the bug for user who keeps using initial PW1

This commit is contained in:
NIIBE Yutaka
2011-11-01 11:01:16 +09:00
parent 683253b2eb
commit 447139f74d
2 changed files with 5 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
2011-11-01 Niibe Yutaka <gniibe@fsij.org> 2011-11-01 Niibe Yutaka <gniibe@fsij.org>
* src/ac.c (verify_user_0): Fix for non-initialized PW1.
* src/Makefile.in (MCFLAGS): Override MCFLAGS option for newer * src/Makefile.in (MCFLAGS): Override MCFLAGS option for newer
GCC of summon-arm-toolchain to add -mfix-cortex-m3-ldrd. GCC of summon-arm-toolchain to add -mfix-cortex-m3-ldrd.
NOTE: This should not be needed (as -mcpu=cortex-m3 defaults NOTE: This should not be needed (as -mcpu=cortex-m3 defaults

View File

@@ -75,7 +75,7 @@ verify_user_0 (const uint8_t *pw, int buf_len, int pw_len_known,
|| strncmp ((const char *)pw, OPENPGP_CARD_INITIAL_PW1, pw_len)) || strncmp ((const char *)pw, OPENPGP_CARD_INITIAL_PW1, pw_len))
goto failure; goto failure;
else else
goto success; goto success_one_step;
} }
else else
pw_len = ks_pw1[0]; pw_len = ks_pw1[0];
@@ -88,15 +88,15 @@ verify_user_0 (const uint8_t *pw, int buf_len, int pw_len_known,
return -1; return -1;
} }
success_one_step:
sha1 (pw, pw_len, keystring); sha1 (pw, pw_len, keystring);
if ((r = gpg_do_load_prvkey (GPG_KEY_FOR_SIGNING, BY_USER, keystring)) if ((r = gpg_do_load_prvkey (GPG_KEY_FOR_SIGNING, BY_USER, keystring))
< 0) < 0)
goto failure; goto failure;
else if (r == 0) else if (r == 0)
if (memcmp (ks_pw1+1, keystring, KEYSTRING_MD_SIZE) != 0) if (ks_pw1 != NULL && memcmp (ks_pw1+1, keystring, KEYSTRING_MD_SIZE) != 0)
goto failure; goto failure;
success:
gpg_pw_reset_err_counter (PW_ERR_PW1); gpg_pw_reset_err_counter (PW_ERR_PW1);
return pw_len; return pw_len;
} }