summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Fofanov <avoget@gmail.com>2023-10-18 14:23:22 +0300
committerTomas Mraz <tomas@openssl.org>2023-11-10 11:33:32 +0100
commit26997d66059432e1fa5bf946249a0bf6086dd716 (patch)
treed5ef5ef4e080416714d10195fbd115e0c85541d5
parent0fdf6e0a1b16c9f359c63fd94aaa7648dc8ef24c (diff)
apps/list.c: Check the result of inserting a provider into provider's stack
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22492) (cherry picked from commit 15b83e04a5e125ab873ace1e474790a4a5b44647)
-rw-r--r--apps/list.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/apps/list.c b/apps/list.c
index 7cbef78719..8649598df7 100644
--- a/apps/list.c
+++ b/apps/list.c
@@ -1209,9 +1209,11 @@ static int provider_cmp(const OSSL_PROVIDER * const *a,
static int collect_providers(OSSL_PROVIDER *provider, void *stack)
{
STACK_OF(OSSL_PROVIDER) *provider_stack = stack;
-
- sk_OSSL_PROVIDER_push(provider_stack, provider);
- return 1;
+ /*
+ * If OK - result is the index of inserted data
+ * Error - result is -1 or 0
+ */
+ return sk_OSSL_PROVIDER_push(provider_stack, provider) > 0 ? 1 : 0;
}
static void list_provider_info(void)
@@ -1226,8 +1228,13 @@ static void list_provider_info(void)
BIO_printf(bio_err, "ERROR: Memory allocation\n");
return;
}
+
+ if (OSSL_PROVIDER_do_all(NULL, &collect_providers, providers) != 1) {
+ BIO_printf(bio_err, "ERROR: Memory allocation\n");
+ return;
+ }
+
BIO_printf(bio_out, "Providers:\n");
- OSSL_PROVIDER_do_all(NULL, &collect_providers, providers);
sk_OSSL_PROVIDER_sort(providers);
for (i = 0; i < sk_OSSL_PROVIDER_num(providers); i++) {
const OSSL_PROVIDER *prov = sk_OSSL_PROVIDER_value(providers, i);