-/* $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.
*/
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