lib/otp: opt_md_init do not leak ctx if malloc fails
Change-Id: I21d7d50e11430bea18832854d817405b761c254c
This commit is contained in:
@@ -92,8 +92,6 @@ otp_md_init (OtpKey key,
|
||||
char *p;
|
||||
int len;
|
||||
|
||||
ctx = EVP_MD_CTX_create();
|
||||
|
||||
len = strlen(pwd) + strlen(seed);
|
||||
p = malloc (len + 1);
|
||||
if (p == NULL)
|
||||
@@ -102,6 +100,8 @@ otp_md_init (OtpKey key,
|
||||
strlwr (p);
|
||||
strlcat (p, pwd, len + 1);
|
||||
|
||||
ctx = EVP_MD_CTX_create();
|
||||
|
||||
EVP_DigestInit_ex(ctx, md, NULL);
|
||||
EVP_DigestUpdate(ctx, p, len);
|
||||
EVP_DigestFinal_ex(ctx, res, NULL);
|
||||
|
Reference in New Issue
Block a user