From: Dr. David von Oheimb Date: Sat, 12 Jun 2021 09:27:28 +0000 (+0200) Subject: BIO: prevent crash on NULL BIO for prefix_ctrl() and thus for BIO_set_prefix(), BIO_s... X-Git-Tag: openssl-3.0.0-beta1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d9691f78a67fed1b30b0cf84b2f3601897b9639;p=thirdparty%2Fopenssl.git BIO: prevent crash on NULL BIO for prefix_ctrl() and thus for BIO_set_prefix(), BIO_set_indent(), etc. Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15722) --- diff --git a/crypto/bio/bf_prefix.c b/crypto/bio/bf_prefix.c index 5727c14950e..c9059ca80ae 100644 --- a/crypto/bio/bf_prefix.c +++ b/crypto/bio/bf_prefix.c @@ -151,9 +151,9 @@ static int prefix_write(BIO *b, const char *out, size_t outl, static long prefix_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 0; - PREFIX_CTX *ctx = BIO_get_data(b); + PREFIX_CTX *ctx; - if (ctx == NULL) + if (b == NULL || (ctx = BIO_get_data(b)) == NULL) return -1; switch (cmd) {