diff options
author | Matt Caswell <matt@openssl.org> | 2016-07-21 13:17:29 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-07-29 15:09:57 +0200 |
commit | 65e2d672548e7c4bcb28f1c5c835362830b1745b (patch) | |
tree | 6d87e72458317ce13c8f54aebd368b9965619525 /test/dtlsv1listentest.c | |
parent | Add some SSL BIO tests (diff) | |
download | openssl-65e2d672548e7c4bcb28f1c5c835362830b1745b.tar.xz openssl-65e2d672548e7c4bcb28f1c5c835362830b1745b.zip |
Simplify and rename SSL_set_rbio() and SSL_set_wbio()
SSL_set_rbio() and SSL_set_wbio() are new functions in 1.1.0 and really
should be called SSL_set0_rbio() and SSL_set0_wbio(). The old
implementation was not consistent with what "set0" means though as there
were special cases around what happens if the rbio and wbio are the same.
We were only ever taking one reference on the BIO, and checking everywhere
whether the rbio and wbio are the same so as not to double free.
A better approach is to rename the functions to SSL_set0_rbio() and
SSL_set0_wbio(). If an existing BIO is present it is *always* freed
regardless of whether the rbio and wbio are the same or not. It is
therefore the callers responsibility to ensure that a reference is taken
for *each* usage, i.e. one for the rbio and one for the wbio.
The legacy function SSL_set_bio() takes both the rbio and wbio in one go
and sets them both. We can wrap up the old behaviour in the implementation
of that function, i.e. previously if the rbio and wbio are the same in the
call to this function then the caller only needed to ensure one reference
was passed. This behaviour is retained by internally upping the ref count.
This commit was inspired by BoringSSL commit f715c423224.
RT#4572
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test/dtlsv1listentest.c')
-rw-r--r-- | test/dtlsv1listentest.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/dtlsv1listentest.c b/test/dtlsv1listentest.c index cc7e5f7889..91d78e1301 100644 --- a/test/dtlsv1listentest.c +++ b/test/dtlsv1listentest.c @@ -352,7 +352,7 @@ int main(void) outbio = BIO_new(BIO_s_mem()); if (outbio == NULL) goto err; - SSL_set_wbio(ssl, outbio); + SSL_set0_wbio(ssl, outbio); success = 1; for (i = 0; i < (long)OSSL_NELEM(testpackets) && success; i++) { @@ -365,7 +365,7 @@ int main(void) /* Set Non-blocking IO behaviour */ BIO_set_mem_eof_return(inbio, -1); - SSL_set_rbio(ssl, inbio); + SSL_set0_rbio(ssl, inbio); /* Process the incoming packet */ ret = DTLSv1_listen(ssl, peer); @@ -404,7 +404,7 @@ int main(void) (void)BIO_reset(outbio); inbio = NULL; /* Frees up inbio */ - SSL_set_rbio(ssl, NULL); + SSL_set0_rbio(ssl, NULL); } err: |