summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-06-02 16:50:15 +0200
committerTomas Mraz <tomas@openssl.org>2022-06-06 09:46:03 +0200
commit9f3626f2473bdce53e85eba96e502e950e29e16f (patch)
tree036d7bc4a3726fd5be9f29456c3a08d4aa63f376
parentc5597b2f076fb33b88f318127df8a4f65f587c6b (diff)
downloadopenssl-new-9f3626f2473bdce53e85eba96e502e950e29e16f.tar.gz
Check return value of ossl_parse_property()
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) (cherry picked from commit 4fa5ed5ce5c345eaeaec8b86eda265add467f941)
-rw-r--r--crypto/encode_decode/decoder_meth.c7
-rw-r--r--crypto/encode_decode/encoder_meth.c7
-rw-r--r--providers/implementations/encode_decode/decode_der2key.c2
3 files changed, 11 insertions, 5 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c
index c797084dd2..12f23a6193 100644
--- a/crypto/encode_decode/decoder_meth.c
+++ b/crypto/encode_decode/decoder_meth.c
@@ -210,8 +210,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) {
diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c
index a7b3461034..9418ddf3d5 100644
--- a/crypto/encode_decode/encoder_meth.c
+++ b/crypto/encode_decode/encoder_meth.c
@@ -210,8 +210,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) {
diff --git a/providers/implementations/encode_decode/decode_der2key.c b/providers/implementations/encode_decode/decode_der2key.c
index f6d293f2b8..ebc2d24833 100644
--- a/providers/implementations/encode_decode/decode_der2key.c
+++ b/providers/implementations/encode_decode/decode_der2key.c
@@ -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();