diff options
author | Pauli <paul.dale@oracle.com> | 2018-09-03 23:35:45 +0200 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2018-09-03 23:35:45 +0200 |
commit | fc196a5eb97dc3a5465c37a6761428ddd81b023d (patch) | |
tree | 47b5116217bcab42d2b3e6fa1084cd67d7332480 /crypto/objects/o_names.c | |
parent | hmac_init cleanup and fix key zeroization issue (diff) | |
download | openssl-fc196a5eb97dc3a5465c37a6761428ddd81b023d.tar.xz openssl-fc196a5eb97dc3a5465c37a6761428ddd81b023d.zip |
Make OBJ_NAME case insensitive.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7089)
Diffstat (limited to 'crypto/objects/o_names.c')
-rw-r--r-- | crypto/objects/o_names.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 8f7bc79346..c4355370cb 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -17,26 +17,25 @@ #include <openssl/safestack.h> #include <openssl/e_os2.h> #include "internal/thread_once.h" +#include "internal/lhash.h" #include "obj_lcl.h" +#include "e_os.h" /* * We define this wrapper for two reasons. Firstly, later versions of * DEC C add linkage information to certain functions, which makes it * tricky to use them as values to regular function pointers. - * Secondly, in the EDK2 build environment, the strcmp function is - * actually an external function (AsciiStrCmp) with the Microsoft ABI, - * so we can't transparently assign function pointers to it. - * Arguably the latter is a stupidity of the UEFI environment, but - * since the wrapper solves the DEC C issue too, let's just use the - * same solution. + * Secondly, in the EDK2 build environment, the strcasecmp function is + * actually an external function with the Microsoft ABI, so we can't + * transparently assign function pointers to it. */ #if defined(OPENSSL_SYS_VMS_DECC) || defined(OPENSSL_SYS_UEFI) -static int obj_strcmp(const char *a, const char *b) +static int obj_strcasecmp(const char *a, const char *b) { - return strcmp(a, b); + return strcasecmp(a, b); } #else -#define obj_strcmp strcmp +#define obj_strcasecmp strcasecmp #endif /* @@ -111,8 +110,8 @@ int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), ret = 0; goto out; } - name_funcs->hash_func = OPENSSL_LH_strhash; - name_funcs->cmp_func = obj_strcmp; + name_funcs->hash_func = openssl_lh_strcasehash; + name_funcs->cmp_func = obj_strcasecmp; CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE); push = sk_NAME_FUNCS_push(name_funcs_stack, name_funcs); @@ -149,7 +148,7 @@ static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b) ret = sk_NAME_FUNCS_value(name_funcs_stack, a->type)->cmp_func(a->name, b->name); } else - ret = strcmp(a->name, b->name); + ret = strcasecmp(a->name, b->name); } return ret; } @@ -164,7 +163,7 @@ static unsigned long obj_name_hash(const OBJ_NAME *a) sk_NAME_FUNCS_value(name_funcs_stack, a->type)->hash_func(a->name); } else { - ret = OPENSSL_LH_strhash(a->name); + ret = openssl_lh_strcasehash(a->name); } ret ^= a->type; return ret; @@ -214,8 +213,6 @@ int OBJ_NAME_add(const char *name, int type, const char *data) if (!OBJ_NAME_init()) return 0; - CRYPTO_THREAD_write_lock(obj_lock); - alias = type & OBJ_NAME_ALIAS; type &= ~OBJ_NAME_ALIAS; @@ -230,6 +227,8 @@ int OBJ_NAME_add(const char *name, int type, const char *data) onp->type = type; onp->data = data; + CRYPTO_THREAD_write_lock(obj_lock); + ret = lh_OBJ_NAME_insert(names_lh, onp); if (ret != NULL) { /* free things */ |