summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2017-05-26 16:32:14 +0000
committerjsing <>2017-05-26 16:32:14 +0000
commit351c9db3f70cc53981f6bded371e0d6ffa33e580 (patch)
tree277cacbf1412f84b1289d4824b78dd7768d181a0 /src
parent6af6efaf8ad642d0bac32b3da8d0ea20559fd121 (diff)
downloadopenbsd-351c9db3f70cc53981f6bded371e0d6ffa33e580.tar.gz
openbsd-351c9db3f70cc53981f6bded371e0d6ffa33e580.tar.bz2
openbsd-351c9db3f70cc53981f6bded371e0d6ffa33e580.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 'src')
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c8
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,