summaryrefslogtreecommitdiff
path: root/usr.bin/openssl
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-08-31 18:39:26 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-08-31 18:39:26 +0000
commit3e89dcf7bf7bfe4e20771a076a57f43154f3d0c5 (patch)
treec2ae28595d2acd42eff9ca389240c9a6103fed88 /usr.bin/openssl
parent199860d7edae2f3963cbd9245aed4ba483916bc4 (diff)
sync x509v3_add_value with x509_utl.c
Diffstat (limited to 'usr.bin/openssl')
-rw-r--r--usr.bin/openssl/ocsp.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/usr.bin/openssl/ocsp.c b/usr.bin/openssl/ocsp.c
index ace843cce1d..d35940a7aed 100644
--- a/usr.bin/openssl/ocsp.c
+++ b/usr.bin/openssl/ocsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ocsp.c,v 1.25 2024/08/30 17:26:44 tb Exp $ */
+/* $OpenBSD: ocsp.c,v 1.26 2024/08/31 18:39:25 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -187,40 +187,53 @@ ocsp_opt_cert_id_md(int argc, char **argv, int *argsused)
static int
x509v3_add_value(const char *name, const char *value,
- STACK_OF(CONF_VALUE) **extlist)
+ STACK_OF(CONF_VALUE) **out_extlist)
{
- CONF_VALUE *vtmp = NULL;
- STACK_OF(CONF_VALUE) *free_exts = NULL;
+ STACK_OF(CONF_VALUE) *extlist = NULL;
+ CONF_VALUE *conf_value = NULL;
+ int ret = 0;
- if ((vtmp = calloc(1, sizeof(CONF_VALUE))) == NULL)
+ if ((conf_value = calloc(1, sizeof(*conf_value))) == NULL) {
+ X509V3error(ERR_R_MALLOC_FAILURE);
goto err;
+ }
if (name != NULL) {
- if ((vtmp->name = strdup(name)) == NULL)
+ if ((conf_value->name = strdup(name)) == NULL) {
+ X509V3error(ERR_R_MALLOC_FAILURE);
goto err;
+ }
}
if (value != NULL) {
- if ((vtmp->value = strdup(value)) == NULL)
+ if ((conf_value->value = strdup(value)) == NULL) {
+ X509V3error(ERR_R_MALLOC_FAILURE);
goto err;
+ }
}
- if (*extlist == NULL) {
- if ((free_exts = *extlist = sk_CONF_VALUE_new_null()) == NULL)
- goto err;
+ if ((extlist = *out_extlist) == NULL)
+ extlist = sk_CONF_VALUE_new_null();
+ if (extlist == NULL) {
+ X509V3error(ERR_R_MALLOC_FAILURE);
+ goto err;
}
- if (!sk_CONF_VALUE_push(*extlist, vtmp))
+ if (!sk_CONF_VALUE_push(extlist, conf_value)) {
+ X509V3error(ERR_R_MALLOC_FAILURE);
goto err;
+ }
+ conf_value = NULL;
- return 1;
+ *out_extlist = extlist;
+ extlist = NULL;
+
+ ret = 1;
err:
- X509V3error(ERR_R_MALLOC_FAILURE);
- X509V3_conf_free(vtmp);
- if (free_exts != NULL) {
- sk_CONF_VALUE_free(*extlist);
- *extlist = NULL;
- }
- return 0;
+ if (extlist != *out_extlist)
+ sk_CONF_VALUE_pop_free(extlist, X509V3_conf_free);
+ X509V3_conf_free(conf_value);
+
+ return ret;
}
static int