提交 9e442d48 编写于 作者: M Matt Caswell

Fix a failure to NULL a pointer freed on error.

Inspired by BoringSSL commit 517073cd4b by Eric Roman <eroman@chromium.org>

CVE-2015-0209
Reviewed-by: NEmilia Käsper <emilia@openssl.org>
上级 71ea6b48
...@@ -1033,8 +1033,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) ...@@ -1033,8 +1033,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE); ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
if (a)
*a = ret;
} else } else
ret = *a; ret = *a;
...@@ -1102,10 +1100,12 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) ...@@ -1102,10 +1100,12 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
ret->enc_flag |= EC_PKEY_NO_PUBKEY; ret->enc_flag |= EC_PKEY_NO_PUBKEY;
} }
if (a)
*a = ret;
ok = 1; ok = 1;
err: err:
if (!ok) { if (!ok) {
if (ret) if (ret && (a == NULL || *a != ret))
EC_KEY_free(ret); EC_KEY_free(ret);
ret = NULL; ret = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册