]> code.ossystems Code Review - openembedded-core.git/blob
d7047bbaacde176d7c609b7ec7b5fdd6dc269e11
[openembedded-core.git] /
1 openssl: avoid NULL pointer dereference in dh_pub_encode()/dsa_pub_encode()
2
3 We should avoid accessing the pointer if ASN1_STRING_new()
4 allocates memory failed.
5
6 Upstream-Status: Submitted
7 http://www.mail-archive.com/openssl-dev@openssl.org/msg32859.html
8
9 Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
10 ---
11 Index: openssl-1.0.2/crypto/dh/dh_ameth.c
12 ===================================================================
13 --- openssl-1.0.2.orig/crypto/dh/dh_ameth.c
14 +++ openssl-1.0.2/crypto/dh/dh_ameth.c
15 @@ -161,6 +161,11 @@ static int dh_pub_encode(X509_PUBKEY *pk
16      dh = pkey->pkey.dh;
17  
18      str = ASN1_STRING_new();
19 +    if (!str) {
20 +        DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE);
21 +        goto err;
22 +    }
23 +
24      str->length = i2d_dhp(pkey, dh, &str->data);
25      if (str->length <= 0) {
26          DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE);