]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Makle STORE_LOADER not do ref counting
authorNeil Horman <nhorman@openssl.org>
Fri, 8 May 2026 14:47:16 +0000 (10:47 -0400)
committerNeil Horman <nhorman@openssl.org>
Thu, 25 Jun 2026 21:25:43 +0000 (17:25 -0400)
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Thu Jun 25 21:26:13 2026
(Merged from https://github.com/openssl/openssl/pull/31143)

crypto/store/store_meth.c

index 04c8a8d5f9efc497f1f2d712b601dedadd901ea7..840ddc1a4a5e2f10994a96b20aec99e3f4cdf947 100644 (file)
@@ -16,8 +16,9 @@
 #include "store_local.h"
 #include "crypto/context.h"
 
-int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader)
+static int up_ref_loader(void *method)
 {
+    OSSL_STORE_LOADER *loader = (OSSL_STORE_LOADER *)method;
     int ref = 0;
 
     if (loader->prov != NULL)
@@ -25,8 +26,10 @@ int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader)
     return 1;
 }
 
-void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader)
+static void free_loader(void *method)
 {
+    OSSL_STORE_LOADER *loader = (OSSL_STORE_LOADER *)method;
+
     if (loader != NULL && loader->prov != NULL) {
         int i;
 
@@ -39,6 +42,22 @@ void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader)
     OPENSSL_free(loader);
 }
 
+int OSSL_STORE_LOADER_up_ref(OSSL_STORE_LOADER *loader)
+{
+#ifdef OPENSSL_NO_CACHED_FETCH
+    return up_ref_loader(loader);
+#else
+    return 1;
+#endif
+}
+
+void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader)
+{
+#ifdef OPENSSL_NO_CACHED_FETCH
+    free_loader(loader);
+#endif
+}
+
 /*
  * OSSL_STORE_LOADER_new() expects the scheme as a constant string,
  * which we currently don't have, so we need an alternative allocator.
@@ -61,16 +80,6 @@ static OSSL_STORE_LOADER *new_loader(OSSL_PROVIDER *prov)
     return loader;
 }
 
-static int up_ref_loader(void *method)
-{
-    return OSSL_STORE_LOADER_up_ref(method);
-}
-
-static void free_loader(void *method)
-{
-    OSSL_STORE_LOADER_free(method);
-}
-
 /* Data to be passed through ossl_method_construct() */
 struct loader_data_st {
     OSSL_LIB_CTX *libctx;
@@ -237,7 +246,7 @@ static void *loader_from_algorithm(int scheme_id, const OSSL_ALGORITHM *algodef,
         || loader->p_eof == NULL
         || loader->p_close == NULL) {
         /* Only set_ctx_params is optional */
-        OSSL_STORE_LOADER_free(loader);
+        free_loader(loader);
         ERR_raise(ERR_LIB_OSSL_STORE, OSSL_STORE_R_LOADER_INCOMPLETE);
         return NULL;
     }
@@ -282,7 +291,7 @@ static void *construct_loader(const OSSL_ALGORITHM *algodef,
 /* Intermediary function to avoid ugly casts, used below */
 static void destruct_loader(void *method, void *data)
 {
-    OSSL_STORE_LOADER_free(method);
+    free_loader(method);
 }
 
 /* Fetching support.  Can fetch by numeric identity or by scheme */