summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorNeil Horman <nhorman@openssl.org>2023-12-16 15:32:48 -0500
committerNeil Horman <nhorman@openssl.org>2024-02-16 09:11:41 -0500
commite6086dd639e62aa6baa6223f38b31b515e4956d5 (patch)
tree726d888c81a006a7eb2eda84666e6e3d6f7860db /crypto
parenta2ccaa666545c4c8dd501e6739d88b4e4d9199be (diff)
Check for NULL cleanup function before using it in encoder_process
encoder_process assumes a cleanup function has been set in the currently in-use encoder during processing, which can lead to segfaults if said function hasn't been set Add a NULL check for this condition, returning -1 if it is not set Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23069) (cherry picked from commit cf57c3ecfa416afbc47d36633981034809ee6792)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/encode_decode/encoder_lib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c
index 28dae99dc8..945b5ba148 100644
--- a/crypto/encode_decode/encoder_lib.c
+++ b/crypto/encode_decode/encoder_lib.c
@@ -59,6 +59,11 @@ int OSSL_ENCODER_to_bio(OSSL_ENCODER_CTX *ctx, BIO *out)
return 0;
}
+ if (ctx->cleanup == NULL || ctx->construct == NULL) {
+ ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_INIT_FAIL);
+ return 0;
+ }
+
return encoder_process(&data) > 0;
}