password_pbkdf2: fix memory leak
Found by: Coverity scan. CID: 96656
This commit is contained in:
parent
5db2190f2c
commit
f3c84fa798
1 changed files with 9 additions and 8 deletions
|
@ -45,6 +45,7 @@ check_password (const char *user, const char *entered, void *pin)
|
||||||
grub_uint8_t *buf;
|
grub_uint8_t *buf;
|
||||||
struct pbkdf2_password *pass = pin;
|
struct pbkdf2_password *pass = pin;
|
||||||
gcry_err_code_t err;
|
gcry_err_code_t err;
|
||||||
|
grub_err_t ret;
|
||||||
|
|
||||||
buf = grub_malloc (pass->buflen);
|
buf = grub_malloc (pass->buflen);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -55,17 +56,17 @@ check_password (const char *user, const char *entered, void *pin)
|
||||||
pass->salt, pass->saltlen, pass->c,
|
pass->salt, pass->saltlen, pass->c,
|
||||||
buf, pass->buflen);
|
buf, pass->buflen);
|
||||||
if (err)
|
if (err)
|
||||||
|
ret = grub_crypto_gcry_error (err);
|
||||||
|
else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
|
||||||
|
ret = GRUB_ACCESS_DENIED;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
grub_free (buf);
|
grub_auth_authenticate (user);
|
||||||
return grub_crypto_gcry_error (err);
|
ret = GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0)
|
grub_free (buf);
|
||||||
return GRUB_ACCESS_DENIED;
|
return ret;
|
||||||
|
|
||||||
grub_auth_authenticate (user);
|
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
Loading…
Reference in a new issue