Hi everybody,

we have written a server application wich uses openssl. now we found out, that memory increases rapidly. Then we found out, that there are memory leaks in openssl. so try this little program:

#include <openssl/bio.h>
#include <openssl/err.h>
#include <string.h>


void *crypto_mem_leak_cb(unsigned long order, const char *file, int line, int num_bytes, void *addr)
{
printf("Leak: Order: %7d, File: %-28s, Line: %4d, Bytes: %5d, Addr: %p\n", order, file, line, num_bytes, addr);
return addr;
}

int main()
{
 CRYPTO_malloc_debug_init();
 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);

 char buffer[] = "Test";

 BIO *bio = BIO_new_mem_buf(buffer, strlen(buffer));
 BIO_free(bio);

 ERR_free_strings();
 ERR_remove_state(0);
 CRYPTO_mem_leaks_cb(crypto_mem_leak_cb);
}

It will output something like this.

Leak: Order: 5, File: .\crypto\stack\stack.c , Line: 126, Bytes: 16, Addr: 003D4210 Leak: Order: 6, File: .\crypto\lhash\lhash.c , Line: 193, Bytes: 12, Addr: 003D4268 Leak: Order: 4, File: .\crypto\stack\stack.c , Line: 124, Bytes: 20, Addr: 003D41B0 Leak: Order: 2, File: .\crypto\lhash\lhash.c , Line: 121, Bytes: 64, Addr: 003D40D0 Leak: Order: 3, File: .\crypto\ex_data.c , Line: 308, Bytes: 12, Addr: 003D4158 Leak: Order: 1, File: .\crypto\lhash\lhash.c , Line: 119, Bytes: 96, Addr: 003D4028


How can we avoid this? we have many certificate operations, so we often use BIOs.

Steffen

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

Reply via email to