diff options
author | tb <> | 2024-08-31 18:39:25 +0000 |
---|---|---|
committer | tb <> | 2024-08-31 18:39:25 +0000 |
commit | 98ed6dfbd497061031832c40b1b8460cfea70a9f (patch) | |
tree | 5c09f10599f829e94a16d69bda394cfe8b537b6b | |
parent | 74ac2d4cae643fdacda23ad7e5f4f43ae67c9c3f (diff) | |
download | openbsd-98ed6dfbd497061031832c40b1b8460cfea70a9f.tar.gz openbsd-98ed6dfbd497061031832c40b1b8460cfea70a9f.tar.bz2 openbsd-98ed6dfbd497061031832c40b1b8460cfea70a9f.zip |
sync x509v3_add_value with x509_utl.c
-rw-r--r-- | src/usr.bin/openssl/ocsp.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/usr.bin/openssl/ocsp.c b/src/usr.bin/openssl/ocsp.c index ace843cce1..d35940a7ae 100644 --- a/src/usr.bin/openssl/ocsp.c +++ b/src/usr.bin/openssl/ocsp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ocsp.c,v 1.25 2024/08/30 17:26:44 tb Exp $ */ | 1 | /* $OpenBSD: ocsp.c,v 1.26 2024/08/31 18:39:25 tb 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 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -187,40 +187,53 @@ ocsp_opt_cert_id_md(int argc, char **argv, int *argsused) | |||
187 | 187 | ||
188 | static int | 188 | static int |
189 | x509v3_add_value(const char *name, const char *value, | 189 | x509v3_add_value(const char *name, const char *value, |
190 | STACK_OF(CONF_VALUE) **extlist) | 190 | STACK_OF(CONF_VALUE) **out_extlist) |
191 | { | 191 | { |
192 | CONF_VALUE *vtmp = NULL; | 192 | STACK_OF(CONF_VALUE) *extlist = NULL; |
193 | STACK_OF(CONF_VALUE) *free_exts = NULL; | 193 | CONF_VALUE *conf_value = NULL; |
194 | int ret = 0; | ||
194 | 195 | ||
195 | if ((vtmp = calloc(1, sizeof(CONF_VALUE))) == NULL) | 196 | if ((conf_value = calloc(1, sizeof(*conf_value))) == NULL) { |
197 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
196 | goto err; | 198 | goto err; |
199 | } | ||
197 | if (name != NULL) { | 200 | if (name != NULL) { |
198 | if ((vtmp->name = strdup(name)) == NULL) | 201 | if ((conf_value->name = strdup(name)) == NULL) { |
202 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
199 | goto err; | 203 | goto err; |
204 | } | ||
200 | } | 205 | } |
201 | if (value != NULL) { | 206 | if (value != NULL) { |
202 | if ((vtmp->value = strdup(value)) == NULL) | 207 | if ((conf_value->value = strdup(value)) == NULL) { |
208 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
203 | goto err; | 209 | goto err; |
210 | } | ||
204 | } | 211 | } |
205 | 212 | ||
206 | if (*extlist == NULL) { | 213 | if ((extlist = *out_extlist) == NULL) |
207 | if ((free_exts = *extlist = sk_CONF_VALUE_new_null()) == NULL) | 214 | extlist = sk_CONF_VALUE_new_null(); |
208 | goto err; | 215 | if (extlist == NULL) { |
216 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
217 | goto err; | ||
209 | } | 218 | } |
210 | 219 | ||
211 | if (!sk_CONF_VALUE_push(*extlist, vtmp)) | 220 | if (!sk_CONF_VALUE_push(extlist, conf_value)) { |
221 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
212 | goto err; | 222 | goto err; |
223 | } | ||
224 | conf_value = NULL; | ||
213 | 225 | ||
214 | return 1; | 226 | *out_extlist = extlist; |
227 | extlist = NULL; | ||
228 | |||
229 | ret = 1; | ||
215 | 230 | ||
216 | err: | 231 | err: |
217 | X509V3error(ERR_R_MALLOC_FAILURE); | 232 | if (extlist != *out_extlist) |
218 | X509V3_conf_free(vtmp); | 233 | sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free); |
219 | if (free_exts != NULL) { | 234 | X509V3_conf_free(conf_value); |
220 | sk_CONF_VALUE_free(*extlist); | 235 | |
221 | *extlist = NULL; | 236 | return ret; |
222 | } | ||
223 | return 0; | ||
224 | } | 237 | } |
225 | 238 | ||
226 | static int | 239 | static int |