summaryrefslogtreecommitdiff
path: root/engines
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 /engines
parent2ff286c26c29b69b02ca99656d26d2f8cfd54682 (diff)
downloadopenssl-new-747adb6a0134e3b707fbc47d0f0c52d6ff9c4223.tar.gz
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 'engines')
-rw-r--r--engines/e_loader_attic.c28
-rw-r--r--engines/e_ossltest.c8
2 files changed, 13 insertions, 23 deletions
diff --git a/engines/e_loader_attic.c b/engines/e_loader_attic.c
index 74f297400b..e5557df627 100644
--- a/engines/e_loader_attic.c
+++ b/engines/e_loader_attic.c
@@ -14,7 +14,7 @@
/* We need to use some engine deprecated APIs */
#define OPENSSL_SUPPRESS_DEPRECATED
-/* #include "e_os.h" */
+#include "../e_os.h" /* for stat and strncasecmp */
#include <string.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -42,11 +42,6 @@
DEFINE_STACK_OF(OSSL_STORE_INFO)
-#ifdef _WIN32
-# define stat _stat
-# define strncasecmp _strnicmp
-#endif
-
#ifndef S_ISDIR
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
#endif
@@ -945,6 +940,7 @@ static int file_find_type(OSSL_STORE_LOADER_CTX *ctx)
return 1;
}
+/* This function has quite some overlap with providers/implementations/storemgmt/file_store.c */
static OSSL_STORE_LOADER_CTX *file_open_ex
(const OSSL_STORE_LOADER *loader, const char *uri,
OSSL_LIB_CTX *libctx, const char *propq,
@@ -957,7 +953,7 @@ static OSSL_STORE_LOADER_CTX *file_open_ex
unsigned int check_absolute:1;
} path_data[2];
size_t path_data_n = 0, i;
- const char *path;
+ const char *path, *p = uri, *q;
/*
* First step, just take the URI as is.
@@ -966,20 +962,18 @@ static OSSL_STORE_LOADER_CTX *file_open_ex
path_data[path_data_n++].path = uri;
/*
- * Second step, if the URI appears to start with the 'file' scheme,
+ * Second step, if the URI appears to start with the "file" scheme,
* extract the path and make that the second path to check.
* There's a special case if the URI also contains an authority, then
* the full URI shouldn't be used as a path anywhere.
*/
- if (strncasecmp(uri, "file:", 5) == 0) {
- const char *p = &uri[5];
-
- if (strncmp(&uri[5], "//", 2) == 0) {
+ if (CHECK_AND_SKIP_CASE_PREFIX(p, "file:")) {
+ q = p;
+ if (CHECK_AND_SKIP_PREFIX(q, "//")) {
path_data_n--; /* Invalidate using the full URI */
- if (strncasecmp(&uri[7], "localhost/", 10) == 0) {
- p = &uri[16];
- } else if (uri[7] == '/') {
- p = &uri[7];
+ if (CHECK_AND_SKIP_CASE_PREFIX(q, "localhost/")
+ || CHECK_AND_SKIP_PREFIX(q, "/")) {
+ p = q - 1;
} else {
ATTICerr(0, ATTIC_R_URI_AUTHORITY_UNSUPPORTED);
return NULL;
@@ -988,7 +982,7 @@ static OSSL_STORE_LOADER_CTX *file_open_ex
path_data[path_data_n].check_absolute = 1;
#ifdef _WIN32
- /* Windows file: URIs with a drive letter start with a / */
+ /* Windows "file:" URIs with a drive letter start with a '/' */
if (p[0] == '/' && p[2] == ':' && p[3] == '/') {
char c = tolower(p[1]);
diff --git a/engines/e_ossltest.c b/engines/e_ossltest.c
index df0805b197..5b25a0eaf1 100644
--- a/engines/e_ossltest.c
+++ b/engines/e_ossltest.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+#include "internal/cryptlib.h"
#include <openssl/engine.h>
#include <openssl/sha.h>
@@ -42,10 +43,6 @@
#include "e_ossltest_err.c"
-#ifdef _WIN32
-# define strncasecmp _strnicmp
-#endif
-
/* Engine Id and Name */
static const char *engine_ossltest_id = "ossltest";
static const char *engine_ossltest_name = "OpenSSL Test engine support";
@@ -383,9 +380,8 @@ static EVP_PKEY *load_key(ENGINE *eng, const char *key_id, int pub,
BIO *in;
EVP_PKEY *key;
- if (strncasecmp(key_id, "ot:", 3) != 0)
+ if (!CHECK_AND_SKIP_CASE_PREFIX(key_id, "ot:"))
return NULL;
- key_id += 3;
fprintf(stderr, "[ossltest]Loading %s key %s\n",
pub ? "Public" : "Private", key_id);