Lars,

I assume you are running this inside a loop inside of main() and that is how you can tell there is a leak?

Joe




Lars Uhlmann wrote:
Please reference http://www.openssl.org/support/faq.html#PROG13 --
> "I think I've detected a memory leak, is this a bug?"

Thanks!

It doesn't matter if I call those cleaning functions, the leaks are
still there.

/* --- cut here --- */
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/engine.h>
#include <openssl/conf.h>

int main(int argc, char *argv[])
{
        SSL_library_init();

        //ERR_remove_state(0);
        //ERR_free_strings();
        ENGINE_cleanup();
        CONF_modules_unload(1);

        return 1;
}
/* --- cut here --- */

valgrind: still reachable: 1,336 bytes in 81 blocks.
What now?

My problem is, I dont't know _where to read_ about doing it right. The large output about blocks allocated from openssl makes it hard to find my own leaks. That's quite confusing.

These functions I'm now using. Can someone please look at it and tell me a little bit more where I should pay attention about freeing things?

,-----
| SSL_library_init();
|
| SSL_CTX* pCtx = SSL_CTX_new(SSLv3_client_method())
|
| SSL_CTX_use_certificate_chain_file(pCtx, "client.crt")
| SSL_CTX_use_PrivateKey_file(pCtx, "client.key", SSL_FILETYPE_PEM)
| SSL_CTX_check_private_key(pCtx)
| SSL_CTX_load_verify_locations(pCtx, "ca.crt", NULL))
|
| BIO* pBio = BIO_new_buffer_ssl_connect(pCtx)
|
| BIO_get_ssl(pBio, &pSsl);
| SSL_set_mode(pSsl, SSL_MODE_AUTO_RETRY);
|
| BIO_set_conn_hostname(pBio, HOSTNAME);
| BIO_set_conn_port(pBio, HTTPS_PORT);
| BIO_do_connect(pBio)
|
| SSL_CTX_set_verify(pCtx, VERIFY_SWITCHES, NULL);
| SSL_CTX_set_verify_depth(pCtx, 1);
|
| SSL_get_verify_result(pSsl)
|
| BIO_write(pBio, REQUEST, sizeof(REQUEST));
| BIO_flush(pBio)
| BIO_gets(pBio, buffer, buffer_size);
|
| SSL_CTX_free(pCtx);
| BIO_free_all(pBio);
`-----

thanks in advance
Lars
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to