summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/x_pkey.c
diff options
context:
space:
mode:
authormiod <>2014-06-27 04:41:09 +0000
committermiod <>2014-06-27 04:41:09 +0000
commit9284be583ffaee688afc6bd5c5b5b23cdf59ea00 (patch)
tree471008404dddccfd44baa51e2ca76102479c8498 /src/lib/libcrypto/asn1/x_pkey.c
parent4716a776432b47e6ff7f013cce20e596507891b9 (diff)
downloadopenbsd-9284be583ffaee688afc6bd5c5b5b23cdf59ea00.tar.gz
openbsd-9284be583ffaee688afc6bd5c5b5b23cdf59ea00.tar.bz2
openbsd-9284be583ffaee688afc6bd5c5b5b23cdf59ea00.zip
Remove M_ASN1_New* macros which are only used in X509_PKEY_new() are obfuscate
it to hide memory leaks in the error paths, and fix aforementioned memory leaks. ok jsing@ logan@ deraadt@
Diffstat (limited to 'src/lib/libcrypto/asn1/x_pkey.c')
-rw-r--r--src/lib/libcrypto/asn1/x_pkey.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libcrypto/asn1/x_pkey.c b/src/lib/libcrypto/asn1/x_pkey.c
index 2e7745315f..bbf7666b54 100644
--- a/src/lib/libcrypto/asn1/x_pkey.c
+++ b/src/lib/libcrypto/asn1/x_pkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_pkey.c,v 1.11 2014/06/12 15:49:27 deraadt Exp $ */ 1/* $OpenBSD: x_pkey.c,v 1.12 2014/06/27 04:41:09 miod 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 *
@@ -107,12 +107,22 @@ X509_PKEY *
107X509_PKEY_new(void) 107X509_PKEY_new(void)
108{ 108{
109 X509_PKEY *ret = NULL; 109 X509_PKEY *ret = NULL;
110 ASN1_CTX c;
111 110
112 M_ASN1_New_Malloc(ret, X509_PKEY); 111 if ((ret = malloc(sizeof(X509_PKEY))) == NULL) {
112 ASN1_MAC_H_err(ASN1_F_X509_PKEY_NEW, ERR_R_MALLOC_FAILURE,
113 __LINE__);
114 return NULL;
115 }
113 ret->version = 0; 116 ret->version = 0;
114 M_ASN1_New(ret->enc_algor, X509_ALGOR_new); 117 if ((ret->enc_algor = X509_ALGOR_new()) == NULL) {
115 M_ASN1_New(ret->enc_pkey, M_ASN1_OCTET_STRING_new); 118 free(ret);
119 return NULL;
120 }
121 if ((ret->enc_pkey = M_ASN1_OCTET_STRING_new()) == NULL) {
122 X509_ALGOR_free(ret->enc_algor);
123 free(ret);
124 return NULL;
125 }
116 ret->dec_pkey = NULL; 126 ret->dec_pkey = NULL;
117 ret->key_length = 0; 127 ret->key_length = 0;
118 ret->key_data = NULL; 128 ret->key_data = NULL;
@@ -121,7 +131,6 @@ X509_PKEY_new(void)
121 memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH); 131 memset(ret->cipher.iv, 0, EVP_MAX_IV_LENGTH);
122 ret->references = 1; 132 ret->references = 1;
123 return (ret); 133 return (ret);
124 M_ASN1_New_Error(ASN1_F_X509_PKEY_NEW);
125} 134}
126 135
127void 136void