Is BIO_free(second_bio) needed when using BIO_new_bio_pair()?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Is BIO_free(second_bio) needed when using BIO_new_bio_pair()?

Iñaki Baz Castillo
Hi, the ocumentation about BIO_new_bio_pair seems confusing. The doc
at https://www.openssl.org/docs/crypto/BIO_s_bio.html clearly says:

----------------------------
Both halves of a BIO pair should be freed. That is even if one half is
implicit freed due to a BIO_free_all() or SSL_free() call the other
half needs to be freed.

EXAMPLE

BIO *internal_bio, *network_bio;
BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
SSL_set_bio(ssl, internal_bio, internal_bio);
...
SSL_free(ssl);                /* implicitly frees internal_bio */
BIO_free(network_bio);
----------------------------


First of all the example in the doc is wrong:

--------------
BIO *internal_bio, *network_bio;
BIO_new_bio_pair(internal_bio, 0, network_bio, 0);
--------------

It should be:

--------------
BIO *internal_bio, *network_bio;
BIO_new_bio_pair(&internal_bio, 0, &network_bio, 0);
--------------


Is it true that I must call to BIO_free(network_bio)? The SSL_free()
code "seems" to do it by itself!:

--------------------------
void SSL_free(SSL *s)
{
   ...
   if (s->rbio != NULL)
       BIO_free_all(s->rbio);
   if ((s->wbio != NULL) && (s->wbio != s->rbio))
       BIO_free_all(s->wbio);
--------------------------




--
Iñaki Baz Castillo
<[hidden email]>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]