summaryrefslogtreecommitdiffstats
path: root/providers/implementations
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-06-24 11:08:10 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-06-25 12:21:36 +0200
commit5fc0992fc748ec182ef5a8191807a18ecccbb4ce (patch)
treef9193921d6970c6193ea4a1512949e034f9b1b9a /providers/implementations
parentd5567d5f6ea4773d419051f85cfdae3927519a76 (diff)
Fix file_name_check() in storemgmt/file_store.c and e_loader_attic.c
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15892)
Diffstat (limited to 'providers/implementations')
-rw-r--r--providers/implementations/storemgmt/file_store.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/providers/implementations/storemgmt/file_store.c b/providers/implementations/storemgmt/file_store.c
index d9c465581e..4f1e2de650 100644
--- a/providers/implementations/storemgmt/file_store.c
+++ b/providers/implementations/storemgmt/file_store.c
@@ -7,6 +7,8 @@
* https://www.openssl.org/source/license.html
*/
+/* This file has quite some overlap with engines/e_loader_attic.c */
+
#include "e_os.h" /* To get strncasecmp() on Windows */
#include <string.h>
@@ -577,6 +579,7 @@ static char *file_name_to_uri(struct file_ctx_st *ctx, const char *name)
static int file_name_check(struct file_ctx_st *ctx, const char *name)
{
const char *p = NULL;
+ size_t len = strlen(ctx->_.dir.search_name);
/* If there are no search criteria, all names are accepted */
if (ctx->_.dir.search_name[0] == '\0')
@@ -591,11 +594,9 @@ static int file_name_check(struct file_ctx_st *ctx, const char *name)
/*
* First, check the basename
*/
- if (strncasecmp(name, ctx->_.dir.search_name,
- sizeof(ctx->_.dir.search_name) - 1) != 0
- || name[sizeof(ctx->_.dir.search_name) - 1] != '.')
+ if (strncasecmp(name, ctx->_.dir.search_name, len) != 0 || name[len] != '.')
return 0;
- p = &name[sizeof(ctx->_.dir.search_name)];
+ p = &name[len + 1];
/*
* Then, if the expected type is a CRL, check that the extension starts