提交 6541d9e2 编写于 作者: R Richard Levitte

STORE 'file' scheme loader: Add info type expectation

Reviewed-by: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2688)
上级 072bfcc9
...@@ -721,6 +721,9 @@ struct ossl_store_loader_ctx_st { ...@@ -721,6 +721,9 @@ struct ossl_store_loader_ctx_st {
int last_errno; int last_errno;
} dir; } dir;
} _; } _;
/* Expected object type. May be unspecified */
int expected_type;
}; };
static void OSSL_STORE_LOADER_CTX_free(OSSL_STORE_LOADER_CTX *ctx) static void OSSL_STORE_LOADER_CTX_free(OSSL_STORE_LOADER_CTX *ctx)
...@@ -908,6 +911,12 @@ static int file_ctrl(OSSL_STORE_LOADER_CTX *ctx, int cmd, va_list args) ...@@ -908,6 +911,12 @@ static int file_ctrl(OSSL_STORE_LOADER_CTX *ctx, int cmd, va_list args)
return ret; return ret;
} }
static int file_expect(OSSL_STORE_LOADER_CTX *ctx, int expected)
{
ctx->expected_type = expected;
return 1;
}
/* Internal function to decode an already opened PEM file */ /* Internal function to decode an already opened PEM file */
OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp) OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp)
{ {
...@@ -1181,6 +1190,7 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx, ...@@ -1181,6 +1190,7 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx,
} else { } else {
int matchcount = -1; int matchcount = -1;
again:
result = file_load_try_repeat(ctx, ui_method, ui_data); result = file_load_try_repeat(ctx, ui_method, ui_data);
if (result != NULL) if (result != NULL)
return result; return result;
...@@ -1251,6 +1261,13 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx, ...@@ -1251,6 +1261,13 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx,
/* We bail out on ambiguity */ /* We bail out on ambiguity */
if (matchcount > 1) if (matchcount > 1)
return NULL; return NULL;
if (result != NULL
&& ctx->expected_type != 0
&& ctx->expected_type != OSSL_STORE_INFO_get_type(result)) {
OSSL_STORE_INFO_free(result);
goto again;
}
} }
return result; return result;
...@@ -1295,7 +1312,7 @@ static OSSL_STORE_LOADER file_loader = ...@@ -1295,7 +1312,7 @@ static OSSL_STORE_LOADER file_loader =
NULL, NULL,
file_open, file_open,
file_ctrl, file_ctrl,
NULL, file_expect,
file_load, file_load,
file_eof, file_eof,
file_error, file_error,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册