summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-08-01 12:11:21 +0100
committerMatt Caswell <matt@openssl.org>2016-08-01 12:11:21 +0100
commitfebb096c4c5d927c3f48f22adce64839721e79dc (patch)
tree4aeeecf84ddd2900f91e7c79917a32f5fe635e75 /crypto/pem
parent1e7c159d0dd8dcbb77bab412e40daa34ab2ed749 (diff)
Fix bad result in i2b_PVK()
The function i2b_PVK() was returning a bad pointer causing subsequent crashes. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pvkfmt.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c
index 05a79e6944..3a27f2d7fc 100644
--- a/crypto/pem/pvkfmt.c
+++ b/crypto/pem/pvkfmt.c
@@ -759,7 +759,7 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel,
pem_password_cb *cb, void *u)
{
int outlen = 24, pklen;
- unsigned char *p = NULL, *salt = NULL;
+ unsigned char *p = NULL, *start = NULL, *salt = NULL;
EVP_CIPHER_CTX *cctx = NULL;
if (enclevel)
outlen += PVK_SALTLEN;
@@ -772,7 +772,7 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel,
if (*out != NULL) {
p = *out;
} else {
- p = OPENSSL_malloc(outlen);
+ start = p = OPENSSL_malloc(outlen);
if (p == NULL) {
PEMerr(PEM_F_I2B_PVK, ERR_R_MALLOC_FAILURE);
return -1;
@@ -829,14 +829,14 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel,
EVP_CIPHER_CTX_free(cctx);
if (*out == NULL)
- *out = p;
+ *out = start;
return outlen;
error:
EVP_CIPHER_CTX_free(cctx);
if (*out == NULL)
- OPENSSL_free(p);
+ OPENSSL_free(start);
return -1;
}