#include <stdio.h>
-#include "cryptlib.h"
+#include "internal/cryptlib.h"
#include <openssl/crypto.h>
#include <openssl/lhash.h>
#include <openssl/buffer.h>
OPENSSL_free(s);
}
-#define string_stack_free(sk) sk_OPENSSL_STRING_pop_free(sk, str_free)
-
static int int_x509_param_set_hosts(X509_VERIFY_PARAM_ID *id, int mode,
const char *name, size_t namelen)
{
if (name && name[namelen - 1] == '\0')
--namelen;
- if (mode == SET_HOST && id->hosts) {
- string_stack_free(id->hosts);
+ if (mode == SET_HOST) {
+ sk_OPENSSL_STRING_pop_free(id->hosts, str_free);
id->hosts = NULL;
}
if (name == NULL || namelen == 0)
sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free);
param->policies = NULL;
paramid = param->id;
- string_stack_free(paramid->hosts);
+ sk_OPENSSL_STRING_pop_free(paramid->hosts, str_free);
paramid->hosts = NULL;
OPENSSL_free(paramid->peername);
+ paramid->peername = NULL;
OPENSSL_free(paramid->email);
paramid->email = NULL;
paramid->emaillen = 0;
X509_VERIFY_PARAM *param;
X509_VERIFY_PARAM_ID *paramid;
- param = OPENSSL_malloc(sizeof(X509_VERIFY_PARAM));
+ param = OPENSSL_zalloc(sizeof(*param));
if (!param)
return NULL;
- paramid = OPENSSL_malloc(sizeof(X509_VERIFY_PARAM));
+ param->id = paramid = OPENSSL_zalloc(sizeof(*paramid));
if (!paramid) {
OPENSSL_free(param);
return NULL;
}
- memset(param, 0, sizeof(X509_VERIFY_PARAM));
- memset(paramid, 0, sizeof(X509_VERIFY_PARAM_ID));
- param->id = paramid;
x509_verify_param_zero(param);
return param;
}
/* Copy the host flags if and only if we're copying the host list */
if (test_x509_verify_param_copy_id(hosts, NULL)) {
- if (dest->id->hosts) {
- string_stack_free(dest->id->hosts);
- dest->id->hosts = NULL;
- }
+ sk_OPENSSL_STRING_pop_free(dest->id->hosts, str_free);
+ dest->id->hosts = NULL;
if (id->hosts) {
dest->id->hosts =
sk_OPENSSL_STRING_deep_copy(id->hosts, str_copy, str_free);
int X509_VERIFY_PARAM_get_count(void)
{
- int num = sizeof(default_table) / sizeof(X509_VERIFY_PARAM);
+ int num = OSSL_NELEM(default_table);
if (param_table)
num += sk_X509_VERIFY_PARAM_num(param_table);
return num;
const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id)
{
- int num = sizeof(default_table) / sizeof(X509_VERIFY_PARAM);
+ int num = OSSL_NELEM(default_table);
if (id < num)
return default_table + id;
return sk_X509_VERIFY_PARAM_value(param_table, id - num);
if (idx != -1)
return sk_X509_VERIFY_PARAM_value(param_table, idx);
}
- return OBJ_bsearch_table(&pm, default_table,
- sizeof(default_table) /
- sizeof(X509_VERIFY_PARAM));
+ return OBJ_bsearch_table(&pm, default_table, OSSL_NELEM(default_table));
}
void X509_VERIFY_PARAM_table_cleanup(void)