summaryrefslogtreecommitdiffstats
path: root/providers/implementations/storemgmt
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 /providers/implementations/storemgmt
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 'providers/implementations/storemgmt')
-rw-r--r--providers/implementations/storemgmt/file_store.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/providers/implementations/storemgmt/file_store.c b/providers/implementations/storemgmt/file_store.c
index 1059c1217d..59d4e084ce 100644
--- a/providers/implementations/storemgmt/file_store.c
+++ b/providers/implementations/storemgmt/file_store.c
@@ -169,6 +169,7 @@ static struct file_ctx_st *file_open_stream(BIO *source, const char *uri,
return NULL;
}
+/* This function has quite some overlap with engines/e_loader_attic.c */
static void *file_open_dir(const char *path, const char *uri, void *provctx)
{
struct file_ctx_st *ctx;
@@ -203,7 +204,7 @@ static void *file_open(void *provctx, const char *uri)
unsigned int check_absolute:1;
} path_data[2];
size_t path_data_n = 0, i;
- const char *path;
+ const char *path, *p = uri, *q;
BIO *bio;
ERR_set_mark();
@@ -215,19 +216,19 @@ static void *file_open(void *provctx, const char *uri)
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 (CHECK_AND_SKIP_PREFIX(p, "//")) {
+ if (CHECK_AND_SKIP_CASE_PREFIX(p, "file:")) {
+ q = p;
+ if (CHECK_AND_SKIP_CASE_PREFIX(q, "//")) {
path_data_n--; /* Invalidate using the full URI */
- if (strncasecmp(p, "localhost/", 10) == 0) {
- p += sizeof("localhost") - 1;
- } else if (*p != '/') {
+ if (CHECK_AND_SKIP_CASE_PREFIX(q, "localhost/")
+ || CHECK_AND_SKIP_CASE_PREFIX(q, "/")) {
+ p = q - 1;
+ } else {
ERR_clear_last_mark();
ERR_raise(ERR_LIB_PROV, PROV_R_URI_AUTHORITY_UNSUPPORTED);
return NULL;
@@ -236,7 +237,7 @@ static void *file_open(void *provctx, const char *uri)
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]);