提交 febb096c 编写于 作者: M Matt Caswell

Fix bad result in i2b_PVK()

The function i2b_PVK() was returning a bad pointer causing subsequent
crashes.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 1e7c159d
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册