diff options
author | Dmitry Belyavskiy <beldmit@gmail.com> | 2022-04-12 12:30:08 +0200 |
---|---|---|
committer | Dmitry Belyavskiy <beldmit@gmail.com> | 2022-04-21 17:12:32 +0200 |
commit | 2c31d942af28a20e87979cbc76c3dd8d162c1a9c (patch) | |
tree | a7927f89d19ef4c9604eb80fbefc4fa1ac2d4734 | |
parent | a8e4ddc6d15b6e6b308428753bc22b12422adacf (diff) |
str[n]casecmp => OPENSSL_strncasecmp
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18103)
66 files changed, 169 insertions, 233 deletions
@@ -2367,7 +2367,7 @@ static char *make_revocation_str(REVINFO_TYPE rev_type, const char *rev_arg) case REV_CRL_REASON: for (i = 0; i < 8; i++) { - if (strcasecmp(rev_arg, crl_reasons[i]) == 0) { + if (OPENSSL_strcasecmp(rev_arg, crl_reasons[i]) == 0) { reason = crl_reasons[i]; break; } @@ -2584,7 +2584,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, } if (reason_str) { for (i = 0; i < NUM_REASONS; i++) { - if (strcasecmp(reason_str, crl_reasons[i]) == 0) { + if (OPENSSL_strcasecmp(reason_str, crl_reasons[i]) == 0) { reason_code = i; break; } diff --git a/apps/cmp.c b/apps/cmp.c index 9ea5cee412..5c6bcdad0a 100644 --- a/apps/cmp.c +++ b/apps/cmp.c @@ -1745,7 +1745,7 @@ static int handle_opt_geninfo(OSSL_CMP_CTX *ctx) valptr[0] = '\0'; valptr++; - if (strncasecmp(valptr, "int:", 4) != 0) { + if (OPENSSL_strncasecmp(valptr, "int:", 4) != 0) { CMP_err("missing 'int:' in -geninfo option"); return 0; } diff --git a/apps/ecparam.c b/apps/ecparam.c index 12eed703de..ecce36be71 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -229,7 +229,7 @@ int ecparam_main(int argc, char **argv) point_format, 0); *p = OSSL_PARAM_construct_end(); - if (strcasecmp(curve_name, "SM2") == 0) + if (OPENSSL_strcasecmp(curve_name, "SM2") == 0) gctx_params = EVP_PKEY_CTX_new_from_name(NULL, "sm2", NULL); else gctx_params = EVP_PKEY_CTX_new_from_name(NULL, "ec", NULL); diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 30da6e8a8c..227da4982d 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -688,8 +688,8 @@ int load_cert_certs(const char *uri, int ret = 0; char *pass_string; - if (exclude_http && (strncasecmp(uri, "http://", 7) == 0 - || strncasecmp(uri, "https://", 8) == 0)) { + if (exclude_http && (OPENSSL_strncasecmp(uri, "http://", 7) == 0 + || OPENSSL_strncasecmp(uri, "https://", 8) == 0)) { BIO_printf(bio_err, "error: HTTP retrieval not allowed for %s\n", desc); return ret; } @@ -1182,20 +1182,20 @@ int set_name_ex(unsigned long *flags, const char *arg) int set_dateopt(unsigned long *dateopt, const char *arg) { - if (strcasecmp(arg, "rfc_822") == 0) + if (OPENSSL_strcasecmp(arg, "rfc_822") == 0) *dateopt = ASN1_DTFLGS_RFC822; - else if (strcasecmp(arg, "iso_8601") == 0) + else if (OPENSSL_strcasecmp(arg, "iso_8601") == 0) *dateopt = ASN1_DTFLGS_ISO8601; return 0; } int set_ext_copy(int *copy_type, const char *arg) { - if (strcasecmp(arg, "none") == 0) + if (OPENSSL_strcasecmp(arg, "none") == 0) *copy_type = EXT_COPY_NONE; - else if (strcasecmp(arg, "copy") == 0) + else if (OPENSSL_strcasecmp(arg, "copy") == 0) *copy_type = EXT_COPY_ADD; - else if (strcasecmp(arg, "copyall") == 0) + else if (OPENSSL_strcasecmp(arg, "copyall") == 0) *copy_type = EXT_COPY_ALL; else return 0; @@ -1275,7 +1275,7 @@ static int set_table_opts(unsigned long *flags, const char *arg, } for (ptbl = in_tbl; ptbl->name; ptbl++) { - if (strcasecmp(arg, ptbl->name) == 0) { + if (OPENSSL_strcasecmp(arg, ptbl->name) == 0) { *flags &= ~ptbl->mask; if (c) *flags |= ptbl->flag; diff --git a/apps/lib/engine_loader.c b/apps/lib/engine_loader.c index c093f31e1b..42775a89f3 100644 --- a/apps/lib/engine_loader.c +++ b/apps/lib/engine_loader.c @@ -71,7 +71,7 @@ static OSSL_STORE_LOADER_CTX *engine_open(const OSSL_STORE_LOADER *loader, char *keyid = NULL; OSSL_STORE_LOADER_CTX *ctx = NULL; - if (strncasecmp(p, ENGINE_SCHEME_COLON, sizeof(ENGINE_SCHEME_COLON) - 1) + if (OPENSSL_strncasecmp(p, ENGINE_SCHEME_COLON, sizeof(ENGINE_SCHEME_COLON) - 1) != 0) return NULL; p += sizeof(ENGINE_SCHEME_COLON) - 1; diff --git a/apps/lib/http_server.c b/apps/lib/http_server.c index 03faac7707..df9575e2cd 100644 --- a/apps/lib/http_server.c +++ b/apps/lib/http_server.c @@ -453,10 +453,11 @@ int http_server_get_asn1_req(const ASN1_ITEM *it, ASN1_VALUE **preq, } *line_end = '\0'; /* https://tools.ietf.org/html/rfc7230#section-6.3 Persistence */ - if (found_keep_alive != NULL && strcasecmp(key, "Connection") == 0) { - if (strcasecmp(value, "keep-alive") == 0) + if (found_keep_alive != NULL + && OPENSSL_strcasecmp(key, "Connection") == 0) { + if (OPENSSL_strcasecmp(value, "keep-alive") == 0) *found_keep_alive = 1; - else if (strcasecmp(value, "close") == 0) + else if (OPENSSL_strcasecmp(value, "close") == 0) *found_keep_alive = 0; } } diff --git a/apps/lib/names.c b/apps/lib/names.c index 5e2e7e147c..462703c646 100644 --- a/apps/lib/names.c +++ b/apps/lib/names.c @@ -11,14 +11,11 @@ #include <openssl/bio.h> #include <openssl/safestack.h> #include "names.h" - -#ifdef _WIN32 -# define strcasecmp _stricmp -#endif +#include "openssl/crypto.h" int name_cmp(const char * const *a, const char * const *b) { - return strcasecmp(*a, *b); + return OPENSSL_strcasecmp(*a, *b); } void collect_names(const char *name, void *vdata) diff --git a/apps/lib/vms_term_sock.c b/apps/lib/vms_term_sock.c index 1b27699b9d..4d9a69b29e 100644 --- a/apps/lib/vms_term_sock.c +++ b/apps/lib/vms_term_sock.c @@ -132,7 +132,7 @@ int main (int argc, char *argv[], char *envp[]) len; LogMessage ("Enter 'q' or 'Q' to quit ..."); - while (strcasecmp (TermBuff, "Q")) { + while (OPENSSL_strcasecmp (TermBuff, "Q")) { /* ** Create the terminal socket */ diff --git a/apps/list.c b/apps/list.c index 9732d6625a..620ce00831 100644 --- a/apps/list.c +++ b/apps/list.c @@ -71,7 +71,7 @@ static void legacy_cipher_fn(const EVP_CIPHER *c, { if (select_name != NULL && (c == NULL - || strcasecmp(select_name, EVP_CIPHER_get0_name(c)) != 0)) + || OPENSSL_strcasecmp(select_name, EVP_CIPHER_get0_name(c)) != 0)) return; if (c != NULL) { BIO_printf(arg, " %s\n", EVP_CIPHER_get0_name(c)); @@ -370,7 +370,7 @@ DEFINE_STACK_OF(EVP_RAND) static int rand_cmp(const EVP_RAND * const *a, const EVP_RAND * const *b) { - int ret = strcasecmp(EVP_RAND_get0_name(*a), EVP_RAND_get0_name(*b)); + int ret = OPENSSL_strcasecmp(EVP_RAND_get0_name(*a), EVP_RAND_get0_name(*b)); if (ret == 0) ret = strcmp(OSSL_PROVIDER_get0_name(EVP_RAND_get0_provider(*a)), @@ -404,7 +404,7 @@ static void list_random_generators(void) const EVP_RAND *m = sk_EVP_RAND_value(rands, i); if (select_name != NULL - && strcasecmp(EVP_RAND_get0_name(m), select_name) != 0) + && OPENSSL_strcasecmp(EVP_RAND_get0_name(m), select_name) != 0) continue; BIO_printf(bio_out, " %s", EVP_RAND_get0_name(m)); BIO_printf(bio_out, " @ %s\n", @@ -463,7 +463,7 @@ static void display_random(const char *name, EVP_RAND_CTX *drbg) if (gettables != NULL) for (; gettables->key != NULL; gettables++) { /* State has been dealt with already, so ignore */ - if (strcasecmp(gettables->key, OSSL_RAND_PARAM_STATE) == 0) + if (OPENSSL_strcasecmp(gettables->key, OSSL_RAND_PARAM_STATE) == 0) continue; /* Outside of verbose mode, we skip non-string values */ if (gettables->data_type != OSSL_PARAM_UTF8_STRING diff --git a/apps/rehash.c b/apps/rehash.c index fb6c08c420..e4a4e14fd4 100644 --- a/apps/rehash.c +++ b/apps/rehash.c @@ -214,7 +214,7 @@ static int handle_symlink(const char *filename, const char *fullpath) return -1; for (type = OSSL_NELEM(suffixes) - 1; type > 0; type--) { const char *suffix = suffixes[type]; - if (strncasecmp(suffix, &filename[i], strlen(suffix)) == 0) + if (OPENSSL_strncasecmp(suffix, &filename[i], strlen(suffix)) == 0) break; } i += strlen(suffixes[type]); @@ -249,7 +249,7 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h) if ((ext = strrchr(filename, '.')) == NULL) goto end; for (i = 0; i < OSSL_NELEM(extensions); i++) { - if (strcasecmp(extensions[i], ext + 1) == 0) + if (OPENSSL_strcasecmp(extensions[i], ext + 1) == 0) break; } if (i >= OSSL_NELEM(extensions)) diff --git a/apps/s_server.c b/apps/s_server.c index ccaec3124b..e93cfa1e2c 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -432,7 +432,7 @@ static int ssl_servername_cb(SSL *s, int *ad, void *arg) return SSL_TLSEXT_ERR_NOACK; if (servername != NULL) { - if (strcasecmp(servername, p->servername)) + if (OPENSSL_strcasecmp(servername, p->servername)) return p->extension_error; if (ctx2 != NULL) { BIO_printf(p->biodebug, "Switching server context.\n"); diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c index ddf68b576f..fe9fc0dd43 100644 --- a/crypto/LPdir_unix.c +++ b/crypto/LPdir_unix.c @@ -141,7 +141,8 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) p--; if (p > (*ctx)->entry_name && p[-1] == ';') p[-1] = '\0'; - if (strcasecmp((*ctx)->entry_name, (*ctx)->previous_entry_name) == 0) + if (OPENSSL_strcasecmp((*ctx)->entry_name, + (*ctx)->previous_entry_name) == 0) goto again; } #endif diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 031a6c936a..0de5785c27 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -10,7 +10,6 @@ /* We need to use some engine deprecated APIs */ #define OPENSSL_SUPPRESS_DEPRECATED -#include "e_os.h" /* for strncasecmp */ #include "internal/cryptlib.h" #include <stdio.h> #include <openssl/asn1t.h> @@ -134,7 +133,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, if (ameth->pkey_flags & ASN1_PKEY_ALIAS) continue; if ((int)strlen(ameth->pem_str) == len - && strncasecmp(ameth->pem_str, str, len) == 0) + && OPENSSL_strncasecmp(ameth->pem_str, str, len) == 0) return ameth; } return NULL; diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index ecff2be02e..59d42daf4a 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -10,7 +10,6 @@ #include "internal/cryptlib.h" #include <openssl/asn1.h> #include <openssl/x509v3.h> -#include "e_os.h" /* strncasecmp() */ #define ASN1_GEN_FLAG 0x10000 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1) @@ -565,7 +564,8 @@ static int asn1_str2tag(const char *tagstr, int len) tntmp = tnst; for (i = 0; i < OSSL_NELEM(tnst); i++, tntmp++) { - if ((len == tntmp->len) && (strncasecmp(tntmp->strnam, tagstr, len) == 0)) + if ((len == tntmp->len) + && (OPENSSL_strncasecmp(tntmp->strnam, tagstr, len) == 0)) return tntmp->tag; } diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index c05c3c6b10..6fe8427dc5 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <string.h> -#include "e_os.h" /* strcasecmp and struct stat */ +#include "e_os.h" /* struct stat */ #ifdef __TANDEM # include <sys/types.h> /* needed for stat.h */ # include <sys/stat.h> /* struct stat */ @@ -192,11 +192,11 @@ static int def_load(CONF *conf, const char *name, long *line) /* Parse a boolean value and fill in *flag. Return 0 on error. */ static int parsebool(const char *pval, int *flag) { - if (strcasecmp(pval, "on") == 0 - || strcasecmp(pval, "true") == 0) { + if (OPENSSL_strcasecmp(pval, "on") == 0 + || OPENSSL_strcasecmp(pval, "true") == 0) { *flag = 1; - } else if (strcasecmp(pval, "off") == 0 - || strcasecmp(pval, "false") == 0) { + } else if (OPENSSL_strcasecmp(pval, "off") == 0 + || OPENSSL_strcasecmp(pval, "false") == 0) { *flag = 0; } else { ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA); @@ -839,8 +839,10 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx) namelen = strlen(filename); - if ((namelen > 5 && strcasecmp(filename + namelen - 5, ".conf") == 0) - || (namelen > 4 && strcasecmp(filename + namelen - 4, ".cnf") == 0)) { + if ((namelen > 5 + && OPENSSL_strcasecmp(filename + namelen - 5, ".conf") == 0) + || (namelen > 4 + && OPENSSL_strcasecmp(filename + namelen - 4, ".cnf") == 0)) { size_t newlen; char *newpath; BIO *bio; diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index 55248affc6..7e11ab1c88 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -7,7 +7,6 @@ * https://www.openssl.org/source/license.html */ -#include "e_os.h" /* strcasecmp */ #include "internal/namemap.h" #include <openssl/lhash.h> #include "crypto/lhash.h" /* ossl_lh_strcasehash */ @@ -49,7 +48,7 @@ static unsigned long namenum_hash(const NAMENUM_ENTRY *n) static int namenum_cmp(const NAMENUM_ENTRY *a, const NAMENUM_ENTRY *b) { - return strcasecmp(a->name, b->name); + return OPENSSL_strcasecmp(a->name, b->name); } static void namenum_free(NAMENUM_ENTRY *n) diff --git a/crypto/dh/dh_group_params.c b/crypto/dh/dh_group_params.c index c71f4053da..7608cbae5a 100644 --- a/crypto/dh/dh_group_params.c +++ b/crypto/dh/dh_group_params.c @@ -23,7 +23,6 @@ #include <openssl/objects.h> #include "internal/nelem.h" #include "crypto/dh.h" -#include "e_os.h" /* strcasecmp */ static DH *dh_param_init(OSSL_LIB_CTX *libctx, const DH_NAMED_GROUP *group) { diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c index 381da71f33..0d84a33322 100644 --- a/crypto/ec/ec_backend.c +++ b/crypto/ec/ec_backend.c @@ -54,7 +54,7 @@ int ossl_ec_encoding_name2id(const char *name) return OPENSSL_EC_NAMED_CURVE; for (i = 0, sz = OSSL_NELEM(encoding_nameid_map); i < sz; i++) { - if (strcasecmp(name, encoding_nameid_map[i].ptr) == 0) + if (OPENSSL_strcasecmp(name, encoding_nameid_map[i].ptr) == 0) return encoding_nameid_map[i].id; } return -1; @@ -91,7 +91,7 @@ static int ec_check_group_type_name2id(const char *name) return 0; for (i = 0, sz = OSSL_NELEM(check_group_type_nameid_map); i < sz; i++) { - if (strcasecmp(name, check_group_type_nameid_map[i].ptr) == 0) + if (OPENSSL_strcasecmp(name, check_group_type_nameid_map[i].ptr) == 0) return check_group_type_nameid_map[i].id; } return -1; @@ -136,7 +136,7 @@ int ossl_ec_pt_format_name2id(const char *name) return (int)POINT_CONVERSION_UNCOMPRESSED; for (i = 0, sz = OSSL_NELEM(format_nameid_map); i < sz; i++) { - if (strcasecmp(name, format_nameid_map[i].ptr) == 0) + if (OPENSSL_strcasecmp(name, format_nameid_map[i].ptr) == 0) return format_nameid_map[i].id; } return -1; diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 745e014d8f..6b0591c6c8 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -22,7 +22,6 @@ #include "crypto/ec.h" #include "internal/nelem.h" #include "ec_local.h" -#include "e_os.h" /* strcasecmp */ /* functions for EC_GROUP objects */ @@ -1592,9 +1591,10 @@ EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[], ERR_raise(ERR_LIB_EC, EC_R_INVALID_FIELD); goto err; } - if (strcasecmp(ptmp->data, SN_X9_62_prime_field) == 0) { + if (OPENSSL_strcasecmp(ptmp->data, SN_X9_62_prime_field) == 0) { is_prime_field = 1; - } else if (strcasecmp(ptmp->data, SN_X9_62_characteristic_two_field) == 0) { + } else if (OPENSSL_strcasecmp(ptmp->data, + SN_X9_62_characteristic_two_field) == 0) { |