diff options
Diffstat (limited to 'deps/boringssl/src/crypto/conf/conf.c')
-rw-r--r-- | deps/boringssl/src/crypto/conf/conf.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/deps/boringssl/src/crypto/conf/conf.c b/deps/boringssl/src/crypto/conf/conf.c index 7070ca8..c1e4e96 100644 --- a/deps/boringssl/src/crypto/conf/conf.c +++ b/deps/boringssl/src/crypto/conf/conf.c @@ -68,6 +68,7 @@ #include "conf_def.h" #include "internal.h" #include "../internal.h" +#include "../lhash/internal.h" DEFINE_LHASH_OF(CONF_VALUE) @@ -76,12 +77,16 @@ struct conf_st { LHASH_OF(CONF_VALUE) *data; }; +static const char kDefaultSectionName[] = "default"; + // The maximum length we can grow a value to after variable expansion. 64k // should be more than enough for all reasonable uses. #define MAX_CONF_VALUE_LENGTH 65536 static uint32_t conf_value_hash(const CONF_VALUE *v) { - return (lh_strhash(v->section) << 2) ^ lh_strhash(v->name); + const uint32_t section_hash = v->section ? OPENSSL_strhash(v->section) : 0; + const uint32_t name_hash = v->name ? OPENSSL_strhash(v->name) : 0; + return (section_hash << 2) ^ name_hash; } static int conf_value_cmp(const CONF_VALUE *a, const CONF_VALUE *b) { @@ -155,12 +160,14 @@ static void value_free(CONF_VALUE *value) { OPENSSL_free(value); } +static void value_free_arg(CONF_VALUE *value, void *arg) { value_free(value); } + void NCONF_free(CONF *conf) { if (conf == NULL || conf->data == NULL) { return; } - lh_CONF_VALUE_doall(conf->data, value_free); + lh_CONF_VALUE_doall_arg(conf->data, value_free_arg, NULL); lh_CONF_VALUE_free(conf->data); OPENSSL_free(conf); } @@ -390,6 +397,10 @@ const char *NCONF_get_string(const CONF *conf, const char *section, const char *name) { CONF_VALUE template, *value; + if (section == NULL) { + section = kDefaultSectionName; + } + OPENSSL_memset(&template, 0, sizeof(template)); template.section = (char *) section; template.name = (char *) name; @@ -538,7 +549,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { goto err; } - section = OPENSSL_strdup("default"); + section = OPENSSL_strdup(kDefaultSectionName); if (section == NULL) { OPENSSL_PUT_ERROR(CONF, ERR_R_MALLOC_FAILURE); goto err; |