diff options
| author | jsing <> | 2017-05-26 16:32:14 +0000 |
|---|---|---|
| committer | jsing <> | 2017-05-26 16:32:14 +0000 |
| commit | 4e14b65a83270a299f916c446d8d04a894ff7d7b (patch) | |
| tree | 277cacbf1412f84b1289d4824b78dd7768d181a0 /src | |
| parent | bfe9e71a80c8b201a92d49f699001810b1a1bb5a (diff) | |
| download | openbsd-4e14b65a83270a299f916c446d8d04a894ff7d7b.tar.gz openbsd-4e14b65a83270a299f916c446d8d04a894ff7d7b.tar.bz2 openbsd-4e14b65a83270a299f916c446d8d04a894ff7d7b.zip | |
Avoid a potential NULL pointer dereference in d2i_ECPrivateKey().
Reported by Robert Swiecki, who found the issue using honggfuzz.
ok bcook@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index dddf71c6e5..b64b7e14d3 100644 --- a/src/lib/libcrypto/ec/ec_asn1.c +++ b/src/lib/libcrypto/ec/ec_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_asn1.c,v 1.23 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.24 2017/05/26 16:32:14 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -1390,8 +1390,14 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) | |||
| 1390 | ECerror(ERR_R_EC_LIB); | 1390 | ECerror(ERR_R_EC_LIB); |
| 1391 | goto err; | 1391 | goto err; |
| 1392 | } | 1392 | } |
| 1393 | |||
| 1393 | pub_oct = ASN1_STRING_data(priv_key->publicKey); | 1394 | pub_oct = ASN1_STRING_data(priv_key->publicKey); |
| 1394 | pub_oct_len = ASN1_STRING_length(priv_key->publicKey); | 1395 | pub_oct_len = ASN1_STRING_length(priv_key->publicKey); |
| 1396 | if (pub_oct == NULL || pub_oct_len <= 0) { | ||
| 1397 | ECerror(EC_R_BUFFER_TOO_SMALL); | ||
| 1398 | goto err; | ||
| 1399 | } | ||
| 1400 | |||
| 1395 | /* save the point conversion form */ | 1401 | /* save the point conversion form */ |
| 1396 | ret->conv_form = (point_conversion_form_t) (pub_oct[0] & ~0x01); | 1402 | ret->conv_form = (point_conversion_form_t) (pub_oct[0] & ~0x01); |
| 1397 | if (!EC_POINT_oct2point(ret->group, ret->pub_key, | 1403 | if (!EC_POINT_oct2point(ret->group, ret->pub_key, |
