mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
scd:openpgp: Add the length check for new PIN.
* scd/app-openpgp.c (do_change_pin): Make sure new PIN length is longer than MINLEN. -- GnuPG-bug-id: 6843 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
91255c3afd
commit
2376cdff13
@ -3499,6 +3499,31 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
|
||||
log_error (_("error getting new PIN: %s\n"), gpg_strerror (rc));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (set_resetcode)
|
||||
{
|
||||
size_t bufferlen = strlen (pinvalue);
|
||||
|
||||
if (bufferlen != 0 && bufferlen < 8)
|
||||
{
|
||||
log_error (_("Reset Code is too short; minimum length is %d\n"), 8);
|
||||
rc = gpg_error (GPG_ERR_BAD_RESET_CODE);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chvno == 3)
|
||||
minlen = 8;
|
||||
|
||||
if (strlen (pinvalue) < minlen)
|
||||
{
|
||||
log_info (_("PIN for CHV%d is too short;"
|
||||
" minimum length is %d\n"), chvno, minlen);
|
||||
rc = gpg_error (GPG_ERR_BAD_PIN);
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3533,15 +3558,7 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
|
||||
}
|
||||
else if (set_resetcode)
|
||||
{
|
||||
size_t bufferlen = strlen (pinvalue);
|
||||
|
||||
if (bufferlen != 0 && bufferlen < 8)
|
||||
{
|
||||
log_error (_("Reset Code is too short; minimum length is %d\n"), 8);
|
||||
rc = gpg_error (GPG_ERR_BAD_RESET_CODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t bufferlen;
|
||||
char *buffer = NULL;
|
||||
|
||||
rc = pin2hash_if_kdf (app, 0, pinvalue, &buffer, &bufferlen);
|
||||
@ -3551,7 +3568,6 @@ do_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr,
|
||||
|
||||
wipe_and_free (buffer, bufferlen);
|
||||
}
|
||||
}
|
||||
else if (reset_mode)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user