summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-07-01 21:26:28 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-07-01 21:26:28 +0000
commit52dbe7fafe63b8d3fceaae53ddfc948264b00db3 (patch)
tree1c7cc955f389c82a7d6b9cf73f5abdab2abfb019 /lib/libssl
parent82e214d54cc6907774153aa597e4d06f29457bc9 (diff)
Avoid a NULL deref in i2d_ECPrivateKey() when an EC_KEY lacks the public key
member (which is perfectly acceptable). From BoringSSL (Adam Langley), commit f71a27920a903c9c36bcb31e68781b17674d3fd2
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/src/crypto/ec/ec_asn1.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libssl/src/crypto/ec/ec_asn1.c b/lib/libssl/src/crypto/ec/ec_asn1.c
index 52f33d8f346..9478e5260a6 100644
--- a/lib/libssl/src/crypto/ec/ec_asn1.c
+++ b/lib/libssl/src/crypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_asn1.c,v 1.7 2014/06/12 15:49:29 deraadt Exp $ */
+/* $OpenBSD: ec_asn1.c,v 1.8 2014/07/01 21:26:27 miod Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -1092,7 +1092,7 @@ i2d_ECPrivateKey(EC_KEY * a, unsigned char **out)
goto err;
}
}
- if (!(a->enc_flag & EC_PKEY_NO_PUBKEY)) {
+ if (!(a->enc_flag & EC_PKEY_NO_PUBKEY) && a->pub_key != NULL) {
priv_key->publicKey = M_ASN1_BIT_STRING_new();
if (priv_key->publicKey == NULL) {
ECerr(EC_F_I2D_ECPRIVATEKEY,