summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPeiwei Hu <jlu.hpw@foxmail.com>2022-01-04 09:10:32 +0800
committerTomas Mraz <tomas@openssl.org>2022-01-05 10:02:31 +0100
commit038a185971c84ea3978a6a8ba799fca46dc919e7 (patch)
tree84d8632a9c932b661504db31c9e7c472f60b0925 /apps
parentf29cb506035e5aecbdae351aeaddbe3b919d8f9c (diff)
apps/passwd.c: free before error exiting
use goto instead of returning directly while error handling Signed-off-by: Peiwei Hu <jlu.hpw@foxmail.com> Reviewed-by: Ben Kaduk <kaduk@mit.edu> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17404) (cherry picked from commit ea4d16bc60dee53feb71997c1e78379eeb69b7ac)
Diffstat (limited to 'apps')
-rw-r--r--apps/passwd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/passwd.c b/apps/passwd.c
index 65cbd9e493..80861b3f3b 100644
--- a/apps/passwd.c
+++ b/apps/passwd.c
@@ -410,7 +410,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
n >>= 1;
}
if (!EVP_DigestFinal_ex(md, buf, NULL))
- return NULL;
+ goto err;
for (i = 0; i < 1000; i++) {
if (!EVP_DigestInit_ex(md2, EVP_md5(), NULL))
@@ -636,7 +636,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
n >>= 1;
}
if (!EVP_DigestFinal_ex(md, buf, NULL))
- return NULL;
+ goto err;
/* P sequence */
if (!EVP_DigestInit_ex(md2, sha, NULL))
@@ -647,7 +647,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
goto err;
if (!EVP_DigestFinal_ex(md2, temp_buf, NULL))
- return NULL;
+ goto err;
if ((p_bytes = OPENSSL_zalloc(passwd_len)) == NULL)
goto err;
@@ -664,7 +664,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
goto err;
if (!EVP_DigestFinal_ex(md2, temp_buf, NULL))
- return NULL;
+ goto err;
if ((s_bytes = OPENSSL_zalloc(salt_len)) == NULL)
goto err;