diff options
author | miod <> | 2014-07-23 20:49:52 +0000 |
---|---|---|
committer | miod <> | 2014-07-23 20:49:52 +0000 |
commit | 0fd923e655a19db310ce5eb91695efa0cf8aab89 (patch) | |
tree | 857f6c670e47cae58b3471cf3725645a860c04a2 /src | |
parent | 16a537cdd77cec5128855400be9397107cbed865 (diff) | |
download | openbsd-0fd923e655a19db310ce5eb91695efa0cf8aab89.tar.gz openbsd-0fd923e655a19db310ce5eb91695efa0cf8aab89.tar.bz2 openbsd-0fd923e655a19db310ce5eb91695efa0cf8aab89.zip |
level_add_node(): if a memory allocation failure causes us to attempt to clean
up and return failure, be sure the cleanup work does NOT free objects which
are still being referenced by other objects.
ok guenther@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/x509v3/pcy_node.c | 11 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/x509v3/pcy_node.c | 11 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/libcrypto/x509v3/pcy_node.c b/src/lib/libcrypto/x509v3/pcy_node.c index 36424ad1d3..839113ea2f 100644 --- a/src/lib/libcrypto/x509v3/pcy_node.c +++ b/src/lib/libcrypto/x509v3/pcy_node.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_node.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: pcy_node.c,v 1.5 2014/07/23 20:49:52 miod Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -139,9 +139,9 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
139 | if (!tree->extra_data) | 139 | if (!tree->extra_data) |
140 | tree->extra_data = sk_X509_POLICY_DATA_new_null(); | 140 | tree->extra_data = sk_X509_POLICY_DATA_new_null(); |
141 | if (!tree->extra_data) | 141 | if (!tree->extra_data) |
142 | goto node_error; | 142 | goto node_error_cond; |
143 | if (!sk_X509_POLICY_DATA_push(tree->extra_data, data)) | 143 | if (!sk_X509_POLICY_DATA_push(tree->extra_data, data)) |
144 | goto node_error; | 144 | goto node_error_cond; |
145 | } | 145 | } |
146 | 146 | ||
147 | if (parent) | 147 | if (parent) |
@@ -149,9 +149,12 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
149 | 149 | ||
150 | return node; | 150 | return node; |
151 | 151 | ||
152 | node_error_cond: | ||
153 | if (level) | ||
154 | node = NULL; | ||
152 | node_error: | 155 | node_error: |
153 | policy_node_free(node); | 156 | policy_node_free(node); |
154 | return 0; | 157 | return NULL; |
155 | } | 158 | } |
156 | 159 | ||
157 | void | 160 | void |
diff --git a/src/lib/libssl/src/crypto/x509v3/pcy_node.c b/src/lib/libssl/src/crypto/x509v3/pcy_node.c index 36424ad1d3..839113ea2f 100644 --- a/src/lib/libssl/src/crypto/x509v3/pcy_node.c +++ b/src/lib/libssl/src/crypto/x509v3/pcy_node.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: pcy_node.c,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ | 1 | /* $OpenBSD: pcy_node.c,v 1.5 2014/07/23 20:49:52 miod Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2004. | 3 | * project 2004. |
4 | */ | 4 | */ |
@@ -139,9 +139,9 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
139 | if (!tree->extra_data) | 139 | if (!tree->extra_data) |
140 | tree->extra_data = sk_X509_POLICY_DATA_new_null(); | 140 | tree->extra_data = sk_X509_POLICY_DATA_new_null(); |
141 | if (!tree->extra_data) | 141 | if (!tree->extra_data) |
142 | goto node_error; | 142 | goto node_error_cond; |
143 | if (!sk_X509_POLICY_DATA_push(tree->extra_data, data)) | 143 | if (!sk_X509_POLICY_DATA_push(tree->extra_data, data)) |
144 | goto node_error; | 144 | goto node_error_cond; |
145 | } | 145 | } |
146 | 146 | ||
147 | if (parent) | 147 | if (parent) |
@@ -149,9 +149,12 @@ level_add_node(X509_POLICY_LEVEL *level, const X509_POLICY_DATA *data, | |||
149 | 149 | ||
150 | return node; | 150 | return node; |
151 | 151 | ||
152 | node_error_cond: | ||
153 | if (level) | ||
154 | node = NULL; | ||
152 | node_error: | 155 | node_error: |
153 | policy_node_free(node); | 156 | policy_node_free(node); |
154 | return 0; | 157 | return NULL; |
155 | } | 158 | } |
156 | 159 | ||
157 | void | 160 | void |