]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
file_store_any: convert to using generated param decoder
authorPauli <ppzgs1@gmail.com>
Thu, 24 Jul 2025 01:24:00 +0000 (11:24 +1000)
committerPauli <ppzgs1@gmail.com>
Wed, 13 Aug 2025 02:01:15 +0000 (12:01 +1000)
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28147)

providers/implementations/storemgmt/file_store_any2obj.c.in

index 3194b0d8edfe1880853c72f7c587c19b7898c8e7..eef6f6f03ca0ddbea3cc5e4aee09637c36bcc792 100644 (file)
@@ -6,6 +6,9 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
 
 /*
  * This is a decoder that's completely internal to the 'file:' store
@@ -30,6 +33,8 @@
 #include <openssl/buffer.h>
 #include <openssl/err.h>
 #include <openssl/asn1err.h>
+#include <openssl/proverr.h>
+#include "internal/cryptlib.h"
 #include <openssl/params.h>
 #include "internal/asn1.h"
 #include "internal/sizes.h"
@@ -65,16 +70,23 @@ static void any2obj_freectx(void *ctx)
     OPENSSL_free(ctx);
 }
 
+{- produce_param_decoder('any2obj_set_ctx_params',
+                         (['OBJECT_PARAM_DATA_STRUCTURE', 'datastruct', 'utf8_string'],
+                         )); -}
+
 static int any2obj_set_ctx_params(void *vctx, const OSSL_PARAM params[])
 {
     struct any2obj_ctx_st *ctx = vctx;
-    const OSSL_PARAM *p;
+    struct any2obj_set_ctx_params_st p;
     char *str;
 
-    p = OSSL_PARAM_locate_const(params, OSSL_OBJECT_PARAM_DATA_STRUCTURE);
+    if (ctx == NULL || !any2obj_set_ctx_params_decoder(params, &p))
+        return 0;
+
     str = ctx->data_structure;
-    if (p != NULL
-        && !OSSL_PARAM_get_utf8_string(p, &str, sizeof(ctx->data_structure)))
+    if (p.datastruct != NULL
+        && !OSSL_PARAM_get_utf8_string(p.datastruct, &str,
+                                       sizeof(ctx->data_structure)))
         return 0;
 
     return 1;
@@ -82,11 +94,7 @@ static int any2obj_set_ctx_params(void *vctx, const OSSL_PARAM params[])
 
 static const OSSL_PARAM *any2obj_settable_ctx_params(ossl_unused void *provctx)
 {
-    static const OSSL_PARAM settables[] = {
-        OSSL_PARAM_utf8_string(OSSL_OBJECT_PARAM_DATA_STRUCTURE, NULL, 0),
-        OSSL_PARAM_END
-    };
-    return settables;
+    return any2obj_set_ctx_params_list;
 }
 
 static int any2obj_decode_final(void *vctx, int objtype, const char *input_type,