Don't attempt to duplicate the BIO state in SSL_dup
authorMatt Caswell <matt@openssl.org>
Tue, 16 Jun 2020 16:40:40 +0000 (17:40 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 30 Jun 2020 09:54:02 +0000 (10:54 +0100)
commit4864a232ee7f901388532f65911866ca2478cfa9
treed85c72e4cf7a2a43916bb51c0c36980c722322e9
parentd3ef3d01accec8cc373661c7f0dd39541a8df96c
Don't attempt to duplicate the BIO state in SSL_dup

SSL_dup attempted to duplicate the BIO state if the source SSL had BIOs
configured for it. This did not work.

Firstly the SSL_dup code was passing a BIO ** as the destination
argument for BIO_dup_state. However BIO_dup_state expects a BIO * for that
parameter. Any attempt to use this will either (1) fail silently, (2) crash
or fail in some other strange way.

Secondly many BIOs do not implement the BIO_CTRL_DUP ctrl required to make
this work.

Thirdly, if rbio == wbio in the original SSL object, then an attempt is made
to up-ref the BIO in the new SSL object - even though it hasn't been set
yet and is NULL. This results in a crash.

This appears to have been broken for a very long time with at least some of
the problems described above coming from SSLeay. The simplest approach is
to just remove this capability from the function.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12245)
doc/man3/SSL_new.pod
ssl/ssl_lib.c