summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbcook <>2018-08-05 13:35:45 +0000
committerbcook <>2018-08-05 13:35:45 +0000
commit4819ddf18546ddf56557b6631a836776ed36435c (patch)
tree43d58ded7490609a78682579a8ef283f5b3cfef6 /src
parentd94f6c9208e326091c9c0989ba6ae67951b493f0 (diff)
downloadopenbsd-4819ddf18546ddf56557b6631a836776ed36435c.tar.gz
openbsd-4819ddf18546ddf56557b6631a836776ed36435c.tar.bz2
openbsd-4819ddf18546ddf56557b6631a836776ed36435c.zip
Fix a memory leak in i2d_RSA_NET on failure of ASN1_STRING_set.
Found by Coverity. Feedback and ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index d2fabf6e87..6c7031677d 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: n_pkey.c,v 1.31 2017/01/29 17:49:22 beck Exp $ */ 1/* $OpenBSD: n_pkey.c,v 1.32 2018/08/05 13:35:45 bcook Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -273,11 +273,11 @@ i2d_RSA_NET(const RSA *a, unsigned char **pp,
273 goto err; 273 goto err;
274 } 274 }
275 275
276 enckey->enckey->digest->data = zz;
276 if (!ASN1_STRING_set(enckey->os, "private-key", -1)) { 277 if (!ASN1_STRING_set(enckey->os, "private-key", -1)) {
277 ASN1error(ERR_R_MALLOC_FAILURE); 278 ASN1error(ERR_R_MALLOC_FAILURE);
278 goto err; 279 goto err;
279 } 280 }
280 enckey->enckey->digest->data = zz;
281 i2d_NETSCAPE_PKEY(pkey, &zz); 281 i2d_NETSCAPE_PKEY(pkey, &zz);
282 282
283 /* Wipe the private key encoding */ 283 /* Wipe the private key encoding */