]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Check return value of ossl_parse_property()
authorTomas Mraz <tomas@openssl.org>
Thu, 2 Jun 2022 14:50:15 +0000 (16:50 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 6 Jun 2022 07:44:53 +0000 (09:44 +0200)
Also check if we have d2i_public_key() function pointer.

Fixes https://github.com/openssl/openssl/pull/18355#issuecomment-1144893289

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18462)

crypto/encode_decode/decoder_meth.c
crypto/encode_decode/encoder_meth.c
providers/implementations/encode_decode/decode_der2key.c

index a08705abb383f7c2ccdc73de4ee7f2f7e299a2b5..11e94dbcc45f75733c83572d59a30b5b3ff89975 100644 (file)
@@ -191,8 +191,11 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
         return NULL;
     }
     decoder->base.algodef = algodef;
-    decoder->base.parsed_propdef
-        = ossl_parse_property(libctx, algodef->property_definition);
+    if ((decoder->base.parsed_propdef
+         = ossl_parse_property(libctx, algodef->property_definition)) == NULL) {
+        OSSL_DECODER_free(decoder);
+        return NULL;
+    }
 
     for (; fns->function_id != 0; fns++) {
         switch (fns->function_id) {
index 7571570d28125428232566985a8e050264fd54af..7a28894b2ca55e309a514d98309985956aee46d4 100644 (file)
@@ -191,8 +191,11 @@ static void *encoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
         return NULL;
     }
     encoder->base.algodef = algodef;
-    encoder->base.parsed_propdef
-        = ossl_parse_property(libctx, algodef->property_definition);
+    if ((encoder->base.parsed_propdef
+         = ossl_parse_property(libctx, algodef->property_definition)) == NULL) {
+        OSSL_ENCODER_free(encoder);
+        return NULL;
+    }
 
     for (; fns->function_id != 0; fns++) {
         switch (fns->function_id) {
index f6d293f2b8c0570e75414a6004c06ac6cc3e25e4..ebc2d24833397ff5c25c09337c637410c3403f19 100644 (file)
@@ -227,7 +227,7 @@ static int der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection,
         derp = der;
         if (ctx->desc->d2i_PUBKEY != NULL)
             key = ctx->desc->d2i_PUBKEY(NULL, &derp, der_len);
-        else
+        else if (ctx->desc->d2i_public_key != NULL)
             key = ctx->desc->d2i_public_key(NULL, &derp, der_len);
         if (key == NULL && ctx->selection != 0) {
             ERR_clear_last_mark();