Hello there, I have a question about using OpenSSL that I haven't been able to find an answer to on Google. I thought I would ask here. Here is my simple program:
#include <stdio.h> #include <stdlib.h> #include <openssl/bio.h> #include <openssl/evp.h> int main() { BIO *mbio; mbio=BIO_new(BIO_s_mem()); BIO_free(mbio); return 0; } I compile it with: gcc -g -Wall biotest.c -lssl (this is on a Fedora Core 3 box, openssl version 0.9.7a). Using valgrind 2.2.0, with a command line: valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./a.out gives me the following output: ==18708== Memcheck, a memory error detector for x86-linux. ==18708== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al. ==18708== Using valgrind-2.2.0, a program supervision framework for x86-linux. ==18708== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al. ==18708== For more details, rerun with: -v ==18708== ==18708== ==18708== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 21 from 1) ==18708== malloc/free: in use at exit: 220 bytes in 6 blocks. ==18708== malloc/free: 8 allocs, 2 frees, 296 bytes allocated. ==18708== For counts of detected errors, rerun with: -v ==18708== searching for pointers to 6 not-freed blocks. ==18708== checked 3337452 bytes. ==18708== ==18708== 220 bytes in 6 blocks are still reachable in loss record 1 of 1 ==18708== at 0x1B904A90: malloc (vg_replace_malloc.c:131) ==18708== by 0x9C020D: (within /lib/libcrypto.so.0.9.7a) ==18708== by 0x9C07BE: CRYPTO_malloc (in /lib/libcrypto.so.0.9.7a) ==18708== by 0xA04A77: lh_new (in /lib/libcrypto.so.0.9.7a) ==18708== ==18708== LEAK SUMMARY: ==18708== definitely lost: 0 bytes in 0 blocks. ==18708== possibly lost: 0 bytes in 0 blocks. ==18708== still reachable: 220 bytes in 6 blocks. ==18708== suppressed: 0 bytes in 0 blocks. So it seems to me that even this very simple program is leaking memory. What I am really trying to do is use the OpenSSL BIO's to do base64 encode/decode (not shown here). Three possibilities occur to me: 1. I am misusing the OpenSSL library (this is the most likely case). 2. Valgrind is mis-reporting what is going on with OpenSSL (although a good tool, I have found that valgrind is not always correct). 3. There actually is a memory leak in OpenSSL. If anybody has any advice for me on what I am doing wrong in the code, or what version of OpenSSL I should upgrade to, I would very much appreciate it. Please CC me on any correspondence; I am not subscribed to the list. Thank you for your time, Chris Lalancette ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]