summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-06-24 10:29:37 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-11-17 15:48:37 +0100
commit747adb6a0134e3b707fbc47d0f0c52d6ff9c4223 (patch)
treef3b93461fdfeef10680e31e763e5b7e9821e1563 /apps
parent2ff286c26c29b69b02ca99656d26d2f8cfd54682 (diff)
Add and use HAS_CASE_PREFIX(), CHECK_AND_SKIP_CASE_PREFIX(), and HAS_CASE_SUFFIX()
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15847)
Diffstat (limited to 'apps')
-rw-r--r--apps/cmp.c3
-rw-r--r--apps/include/engine_loader.h2
-rw-r--r--apps/lib/apps.c4
-rw-r--r--apps/lib/engine_loader.c4
-rw-r--r--apps/rehash.c7
5 files changed, 8 insertions, 12 deletions
diff --git a/apps/cmp.c b/apps/cmp.c
index ae3488553a..589cce1266 100644
--- a/apps/cmp.c
+++ b/apps/cmp.c
@@ -1710,11 +1710,10 @@ static int handle_opt_geninfo(OSSL_CMP_CTX *ctx)
valptr[0] = '\0';
valptr++;
- if (strncasecmp(valptr, "int:", 4) != 0) {
+ if (!CHECK_AND_SKIP_CASE_PREFIX(valptr, "int:")) {
CMP_err("missing 'int:' in -geninfo option");
return 0;
}
- valptr += 4;
value = strtol(valptr, &endstr, 10);
if (endstr == valptr || *endstr != '\0') {
diff --git a/apps/include/engine_loader.h b/apps/include/engine_loader.h
index 11598639a5..97c176c6c8 100644
--- a/apps/include/engine_loader.h
+++ b/apps/include/engine_loader.h
@@ -13,7 +13,7 @@
/* this is a private URI scheme */
# define ENGINE_SCHEME "org.openssl.engine"
-# define ENGINE_SCHEME_COLON (ENGINE_SCHEME ":")
+# define ENGINE_SCHEME_COLON ENGINE_SCHEME ":"
int setup_engine_loader(void);
void destroy_engine_loader(void);
diff --git a/apps/lib/apps.c b/apps/lib/apps.c
index 2c4c292b94..01feedaf3f 100644
--- a/apps/lib/apps.c
+++ b/apps/lib/apps.c
@@ -680,8 +680,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 && (HAS_CASE_PREFIX(uri, "http://")
+ || HAS_CASE_PREFIX(uri, "https://"))) {
BIO_printf(bio_err, "error: HTTP retrieval not allowed for %s\n", desc);
return ret;
}
diff --git a/apps/lib/engine_loader.c b/apps/lib/engine_loader.c
index 2b4480000c..7ea05943f3 100644
--- a/apps/lib/engine_loader.c
+++ b/apps/lib/engine_loader.c
@@ -71,10 +71,8 @@ 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)
- != 0)
+ if (!CHECK_AND_SKIP_CASE_PREFIX(p, ENGINE_SCHEME_COLON))
return NULL;
- p += sizeof(ENGINE_SCHEME_COLON) - 1;
/* Look for engine ID */
q = strchr(p, ':');
diff --git a/apps/rehash.c b/apps/rehash.c
index 7fe01de11c..e0cdc9bc62 100644
--- a/apps/rehash.c
+++ b/apps/rehash.c
@@ -206,11 +206,10 @@ static int handle_symlink(const char *filename, const char *fullpath)
}
if (filename[i++] != '.')
return -1;
- for (type = OSSL_NELEM(suffixes) - 1; type > 0; type--) {
- const char *suffix = suffixes[type];
- if (strncasecmp(suffix, &filename[i], strlen(suffix)) == 0)
+ for (type = OSSL_NELEM(suffixes) - 1; type > 0; type--)
+ if (strncasecmp(&filename[i],
+ suffixes[type], strlen(suffixes[type])) == 0)
break;
- }
i += strlen(suffixes[type]);
id = strtoul(&filename[i], &endptr, 10);