BIO: at the end of BIO_new, declare the BIO inited if no create method present
authorRichard Levitte <levitte@openssl.org>
Wed, 31 Jan 2018 10:17:32 +0000 (11:17 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 31 Jan 2018 16:45:11 +0000 (17:45 +0100)
Without this, every BIO implementation is forced to have a create
method, just to set bio->init = 1.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5223)

crypto/bio/bio_lib.c

index 8a2ec0e..dc4d0a0 100644 (file)
@@ -98,6 +98,8 @@ BIO *BIO_new(const BIO_METHOD *method)
         CRYPTO_THREAD_lock_free(bio->lock);
         goto err;
     }
+    if (method->create == NULL)
+        bio->init = 1;
 
     return bio;