From 52dbe7fafe63b8d3fceaae53ddfc948264b00db3 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Tue, 1 Jul 2014 21:26:28 +0000 Subject: 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 --- lib/libssl/src/crypto/ec/ec_asn1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libssl') 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, -- cgit v1.2.3