summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x509/x509_v3.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c
index 2ab61b173c..0af2ee3ba2 100644
--- a/src/lib/libcrypto/x509/x509_v3.c
+++ b/src/lib/libcrypto/x509/x509_v3.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_v3.c,v 1.39 2024/07/12 09:42:24 tb Exp $ */ 1/* $OpenBSD: x509_v3.c,v 1.40 2024/07/12 09:47:49 tb 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 *
@@ -143,9 +143,9 @@ X509v3_delete_ext(STACK_OF(X509_EXTENSION) *sk, int loc)
143LCRYPTO_ALIAS(X509v3_delete_ext); 143LCRYPTO_ALIAS(X509v3_delete_ext);
144 144
145STACK_OF(X509_EXTENSION) * 145STACK_OF(X509_EXTENSION) *
146X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ext, int loc) 146X509v3_add_ext(STACK_OF(X509_EXTENSION) **out_exts, X509_EXTENSION *ext, int loc)
147{ 147{
148 STACK_OF(X509_EXTENSION) *sk = NULL; 148 STACK_OF(X509_EXTENSION) *exts = NULL;
149 X509_EXTENSION *new_ext = NULL; 149 X509_EXTENSION *new_ext = NULL;
150 150
151 /* 151 /*
@@ -153,32 +153,32 @@ X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ext, int loc)
153 * This check should have been joined with the next check, i.e., if no 153 * This check should have been joined with the next check, i.e., if no
154 * stack was passed in, a new one should be created and returned. 154 * stack was passed in, a new one should be created and returned.
155 */ 155 */
156 if (x == NULL) { 156 if (out_exts == NULL) {
157 X509error(ERR_R_PASSED_NULL_PARAMETER); 157 X509error(ERR_R_PASSED_NULL_PARAMETER);
158 goto err; 158 goto err;
159 } 159 }
160 160
161 if ((sk = *x) == NULL) 161 if ((exts = *out_exts) == NULL)
162 sk = sk_X509_EXTENSION_new_null(); 162 exts = sk_X509_EXTENSION_new_null();
163 if (sk == NULL) { 163 if (exts == NULL) {
164 X509error(ERR_R_MALLOC_FAILURE); 164 X509error(ERR_R_MALLOC_FAILURE);
165 goto err; 165 goto err;
166 } 166 }
167 167
168 if ((new_ext = X509_EXTENSION_dup(ext)) == NULL) 168 if ((new_ext = X509_EXTENSION_dup(ext)) == NULL)
169 goto err; 169 goto err;
170 if (!sk_X509_EXTENSION_insert(sk, new_ext, loc)) 170 if (!sk_X509_EXTENSION_insert(exts, new_ext, loc))
171 goto err; 171 goto err;
172 new_ext = NULL; 172 new_ext = NULL;
173 173
174 *x = sk; 174 *out_exts = exts;
175 175
176 return sk; 176 return exts;
177 177
178 err: 178 err:
179 X509_EXTENSION_free(new_ext); 179 X509_EXTENSION_free(new_ext);
180 if (x != NULL && sk != *x) 180 if (out_exts != NULL && exts != *out_exts)
181 sk_X509_EXTENSION_pop_free(sk, X509_EXTENSION_free); 181 sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free);
182 182
183 return NULL; 183 return NULL;
184} 184}