From 2c31d942af28a20e87979cbc76c3dd8d162c1a9c Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Tue, 12 Apr 2022 12:30:08 +0200 Subject: str[n]casecmp => OPENSSL_strncasecmp Reviewed-by: Tim Hudson Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18103) --- test/bntest.c | 9 +-------- test/evp_extra_test.c | 3 +-- test/evp_libctx_test.c | 3 +-- test/evp_test.c | 19 +++++++++---------- test/helpers/ssl_test_ctx.c | 8 ++------ test/params_conversion_test.c | 36 ++++++++++++++++-------------------- test/ssl_old_test.c | 2 +- test/v3nametest.c | 6 +----- 8 files changed, 32 insertions(+), 54 deletions(-) (limited to 'test') diff --git a/test/bntest.c b/test/bntest.c index 4c1ee0c13b..c5894c157b 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -10,9 +10,6 @@ #include #include #include -#ifdef __TANDEM -# include /* strcasecmp */ -#endif #include #include @@ -23,10 +20,6 @@ #include "internal/numbers.h" #include "testutil.h" -#ifdef OPENSSL_SYS_WINDOWS -# define strcasecmp _stricmp -#endif - /* * Things in boring, not in openssl. */ @@ -64,7 +57,7 @@ static const char *findattr(STANZA *s, const char *key) PAIR *pp = s->pairs; for ( ; --i >= 0; pp++) - if (strcasecmp(pp->key, key) == 0) + if (OPENSSL_strcasecmp(pp->key, key) == 0) return pp->value; return NULL; } diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 826e558cc0..3b59761779 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -35,7 +35,6 @@ #include "internal/nelem.h" #include "internal/sizes.h" #include "crypto/evp.h" -#include "../e_os.h" /* strcasecmp */ static OSSL_LIB_CTX *testctx = NULL; static char *testpropq = NULL; @@ -1739,7 +1738,7 @@ static int ec_export_get_encoding_cb(const OSSL_PARAM params[], void *arg) return 0; for (i = 0; i < OSSL_NELEM(ec_encodings); i++) { - if (strcasecmp(enc_name, ec_encodings[i].encoding_name) == 0) { + if (OPENSSL_strcasecmp(enc_name, ec_encodings[i].encoding_name) == 0) { *enc = ec_encodings[i].encoding; break; } diff --git a/test/evp_libctx_test.c b/test/evp_libctx_test.c index e2663dc029..9b2f4a0168 100644 --- a/test/evp_libctx_test.c +++ b/test/evp_libctx_test.c @@ -33,7 +33,6 @@ #include "testutil.h" #include "internal/nelem.h" #include "crypto/bn_dh.h" /* _bignum_ffdhe2048_p */ -#include "../e_os.h" /* strcasecmp */ static OSSL_LIB_CTX *libctx = NULL; static OSSL_PROVIDER *nullprov = NULL; @@ -478,7 +477,7 @@ err: static int name_cmp(const char * const *a, const char * const *b) { - return strcasecmp(*a, *b); + return OPENSSL_strcasecmp(*a, *b); } static void collect_cipher_names(EVP_CIPHER *cipher, void *cipher_names_list) diff --git a/test/evp_test.c b/test/evp_test.c index 5aed3cfa8f..ef6fc0965a 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -12,7 +12,6 @@ #include #include #include -#include "../e_os.h" /* strcasecmp */ #include #include #include @@ -3925,9 +3924,9 @@ void cleanup_tests(void) OSSL_LIB_CTX_free(libctx); } -#define STR_STARTS_WITH(str, pre) strncasecmp(pre, str, strlen(pre)) == 0 +#define STR_STARTS_WITH(str, pre) OPENSSL_strncasecmp(pre, str, strlen(pre)) == 0 #define STR_ENDS_WITH(str, pre) \ -strlen(str) < strlen(pre) ? 0 : (strcasecmp(pre, str + strlen(str) - strlen(pre)) == 0) +strlen(str) < strlen(pre) ? 0 : (OPENSSL_strcasecmp(pre, str + strlen(str) - strlen(pre)) == 0) static int is_digest_disabled(const char *name) { @@ -3936,31 +3935,31 @@ static int is_digest_disabled(const char *name) return 1; #endif #ifdef OPENSSL_NO_MD2 - if (strcasecmp(name, "MD2") == 0) + if (OPENSSL_strcasecmp(name, "MD2") == 0) return 1; #endif #ifdef OPENSSL_NO_MDC2 - if (strcasecmp(name, "MDC2") == 0) + if (OPENSSL_strcasecmp(name, "MDC2") == 0) return 1; #endif #ifdef OPENSSL_NO_MD4 - if (strcasecmp(name, "MD4") == 0) + if (OPENSSL_strcasecmp(name, "MD4") == 0) return 1; #endif #ifdef OPENSSL_NO_MD5 - if (strcasecmp(name, "MD5") == 0) + if (OPENSSL_strcasecmp(name, "MD5") == 0) return 1; #endif #ifdef OPENSSL_NO_RMD160 - if (strcasecmp(name, "RIPEMD160") == 0) + if (OPENSSL_strcasecmp(name, "RIPEMD160") == 0) return 1; #endif #ifdef OPENSSL_NO_SM3 - if (strcasecmp(name, "SM3") == 0) + if (OPENSSL_strcasecmp(name, "SM3") == 0) return 1; #endif #ifdef OPENSSL_NO_WHIRLPOOL - if (strcasecmp(name, "WHIRLPOOL") == 0) + if (OPENSSL_strcasecmp(name, "WHIRLPOOL") == 0) return 1; #endif return 0; diff --git a/test/helpers/ssl_test_ctx.c b/test/helpers/ssl_test_ctx.c index 1374b04cf0..7236ffd4a6 100644 --- a/test/helpers/ssl_test_ctx.c +++ b/test/helpers/ssl_test_ctx.c @@ -16,21 +16,17 @@ #include "ssl_test_ctx.h" #include "../testutil.h" -#ifdef OPENSSL_SYS_WINDOWS -# define strcasecmp _stricmp -#endif - static const int default_app_data_size = 256; /* Default set to be as small as possible to exercise fragmentation. */ static const int default_max_fragment_size = 512; static int parse_boolean(const char *value, int *result) { - if (strcasecmp(value, "Yes") == 0) { + if (OPENSSL_strcasecmp(value, "Yes") == 0) { *result = 1; return 1; } - else if (strcasecmp(value, "No") == 0) { + else if (OPENSSL_strcasecmp(value, "No") == 0) { *result = 0; return 1; } diff --git a/test/params_conversion_test.c b/test/params_conversion_test.c index 9422ef1473..710c2a9a2e 100644 --- a/test/params_conversion_test.c +++ b/test/params_conversion_test.c @@ -15,10 +15,6 @@ /* On machines that dont support just disable the tests */ #if !defined(OPENSSL_NO_INTTYPES_H) -# ifdef OPENSSL_SYS_WINDOWS -# define strcasecmp _stricmp -# endif - # ifdef OPENSSL_SYS_VMS # define strtoumax strtoull # define strtoimax strtoll @@ -62,7 +58,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) for (i = 0; i < s->numpairs; i++, pp++) { p = ""; - if (strcasecmp(pp->key, "type") == 0) { + if (OPENSSL_strcasecmp(pp->key, "type") == 0) { if (type != NULL) { TEST_info("Line %d: multiple type lines", s->curr); return 0; @@ -72,48 +68,48 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) TEST_info("Line %d: unknown type line", s->curr); return 0; } - } else if (strcasecmp(pp->key, "int32") == 0) { + } else if (OPENSSL_strcasecmp(pp->key, "int32") == 0) { if (def_i32++) { TEST_info("Line %d: multiple int32 lines", s->curr); return 0; } - if (strcasecmp(pp->value, "invalid") != 0) { + if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) { pc->valid_i32 = 1; pc->i32 = (int32_t)strtoimax(pp->value, &p, 10); } - } else if (strcasecmp(pp->key, "int64") == 0) { + } else if (OPENSSL_strcasecmp(pp->key, "int64") == 0) { if (def_i64++) { TEST_info("Line %d: multiple int64 lines", s->curr); return 0; } - if (strcasecmp(pp->value, "invalid") != 0) { + if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) { pc->valid_i64 = 1; pc->i64 = (int64_t)strtoimax(pp->value, &p, 10); } - } else if (strcasecmp(pp->key, "uint32") == 0) { + } else if (OPENSSL_strcasecmp(pp->key, "uint32") == 0) { if (def_u32++) { TEST_info("Line %d: multiple uint32 lines", s->curr); return 0; } - if (strcasecmp(pp->value, "invalid") != 0) { + if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) { pc->valid_u32 = 1; pc->u32 = (uint32_t)strtoumax(pp->value, &p, 10); } - } else if (strcasecmp(pp->key, "uint64") == 0) { + } else if (OPENSSL_strcasecmp(pp->key, "uint64") == 0) { if (def_u64++) { TEST_info("Line %d: multiple uint64 lines", s->curr); return 0; } - if (strcasecmp(pp->value, "invalid") != 0) { + if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) { pc->valid_u64 = 1; pc->u64 = (uint64_t)strtoumax(pp->value, &p, 10); } - } else if (strcasecmp(pp->key, "double") == 0) { + } else if (OPENSSL_strcasecmp(pp->key, "double") == 0) { if (def_d++) { TEST_info("Line %d: multiple double lines", s->curr); return 0; } - if (strcasecmp(pp->value, "invalid") != 0) { + if (OPENSSL_strcasecmp(pp->value, "invalid") != 0) { pc->valid_d = 1; pc->d = strtod(pp->value, &p); } @@ -133,7 +129,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) return 0; } - if (strcasecmp(type, "int32") == 0) { + if (OPENSSL_strcasecmp(type, "int32") == 0) { if (!TEST_true(def_i32) || !TEST_true(pc->valid_i32)) { TEST_note("errant int32 on line %d", s->curr); return 0; @@ -142,7 +138,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) pc->datum = &datum_i32; pc->ref = &ref_i32; pc->size = sizeof(ref_i32); - } else if (strcasecmp(type, "int64") == 0) { + } else if (OPENSSL_strcasecmp(type, "int64") == 0) { if (!TEST_true(def_i64) || !TEST_true(pc->valid_i64)) { TEST_note("errant int64 on line %d", s->curr); return 0; @@ -151,7 +147,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) pc->datum = &datum_i64; pc->ref = &ref_i64; pc->size = sizeof(ref_i64); - } else if (strcasecmp(type, "uint32") == 0) { + } else if (OPENSSL_strcasecmp(type, "uint32") == 0) { if (!TEST_true(def_u32) || !TEST_true(pc->valid_u32)) { TEST_note("errant uint32 on line %d", s->curr); return 0; @@ -160,7 +156,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) pc->datum = &datum_u32; pc->ref = &ref_u32; pc->size = sizeof(ref_u32); - } else if (strcasecmp(type, "uint64") == 0) { + } else if (OPENSSL_strcasecmp(type, "uint64") == 0) { if (!TEST_true(def_u64) || !TEST_true(pc->valid_u64)) { TEST_note("errant uint64 on line %d", s->curr); return 0; @@ -169,7 +165,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) pc->datum = &datum_u64; pc->ref = &ref_u64; pc->size = sizeof(ref_u64); - } else if (strcasecmp(type, "double") == 0) { + } else if (OPENSSL_strcasecmp(type, "double") == 0) { if (!TEST_true(def_d) || !TEST_true(pc->valid_d)) { TEST_note("errant double on line %d", s->curr); return 0; diff --git a/test/ssl_old_test.c b/test/ssl_old_test.c index b07b980624..5fb54a3a2e 100644 --- a/test/ssl_old_test.c +++ b/test/ssl_old_test.c @@ -216,7 +216,7 @@ static int servername_cb(SSL *s, int *ad, void *arg) if (servername) { if (s_ctx2 != NULL && sn_server2 != NULL && - !strcasecmp(servername, sn_server2)) { + !OPENSSL_strcasecmp(servername, sn_server2)) { BIO_printf(bio_stdout, "Switching server context.\n"); SSL_set_SSL_CTX(s, s_ctx2); } diff --git a/test/v3nametest.c b/test/v3nametest.c index 06d713b2fe..ce1f4949fe 100644 --- a/test/v3nametest.c +++ b/test/v3nametest.c @@ -15,10 +15,6 @@ #include "internal/nelem.h" #include "testutil.h" -#ifdef OPENSSL_SYS_WINDOWS -# define strcasecmp _stricmp -#endif - static const char *const names[] = { "a", "b", ".", "*", "@", ".a", "a.", ".b", "b.", ".*", "*.", "*@", "@*", "a@", "@a", "b@", "..", @@ -287,7 +283,7 @@ static int run_cert(X509 *crt, const char *nameincert, int failed = 0; for (; *pname != NULL; ++pname) { - int samename = strcasecmp(nameincert, *pname) == 0; + int samename = OPENSSL_strcasecmp(nameincert, *pname) == 0; size_t namelen = strlen(*pname); char *name = OPENSSL_malloc(namelen + 1); int match, ret; -- cgit v1.2.3