evp_generic_do_all(): fix passing of method data
authorRichard Levitte <levitte@openssl.org>
Tue, 24 Sep 2019 01:42:18 +0000 (03:42 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 17 Oct 2019 07:16:45 +0000 (09:16 +0200)
Method data was passed down as provider to ossl_algorithm_do_all(),
which causes trouble as soon a it's non-NULL.  Pass it via the data
structure instead.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/9979)

crypto/evp/evp_fetch.c

index e2039df..907091f 100644 (file)
@@ -411,6 +411,7 @@ struct do_all_data_st {
     void *user_arg;
     void *(*new_method)(const int name_id, const OSSL_DISPATCH *fns,
                         OSSL_PROVIDER *prov, void *method_data);
+    void *method_data;
     void (*free_method)(void *);
 };
 
@@ -425,7 +426,7 @@ static void do_one(OSSL_PROVIDER *provider, const OSSL_ALGORITHM *algo,
 
     if (name_id != 0)
         method = data->new_method(name_id, algo->implementation, provider,
-                                  NULL);
+                                  data->method_data);
 
     if (method != NULL) {
         data->user_fn(method, data->user_arg);
@@ -446,10 +447,11 @@ void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
     struct do_all_data_st data;
 
     data.new_method = new_method;
+    data.method_data = method_data;
     data.free_method = free_method;
     data.user_fn = user_fn;
     data.user_arg = user_arg;
-    ossl_algorithm_do_all(libctx, operation_id, method_data, do_one, &data);
+    ossl_algorithm_do_all(libctx, operation_id, NULL, do_one, &data);
 }
 
 const char *evp_first_name(OSSL_PROVIDER *prov, int name_id)