Fix ssl3_get_message handle message fragmentation correctly.
[openssl.git] / ssl / ssltest.c
index 865ff7a702de9676e392ed379d0da5ac68dbdc15..0592e6c2a8e467699161279fabff7c6f032d77f6 100644 (file)
  *
  */
 
+#define _XOPEN_SOURCE 600      /* Or gethostname won't be declared properly
+                                  on Linux and GNU platforms. */
+#define _XOPEN_SOURCE_EXTENDED /* Or gethostname won't be declared properly
+                                  on Compaq platforms (at least with DEC C).
+                               */
+
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <openssl/evp.h>
 #include <openssl/x509.h>
 #include <openssl/ssl.h>
+#include <openssl/engine.h>
 #include <openssl/err.h>
 #include <openssl/rand.h>
 #ifdef OPENSSL_SYS_WINDOWS
 #include <winsock.h>
 #include "../crypto/bio/bss_file.c"
+#else
+#include OPENSSL_UNISTD
 #endif
 
 #ifdef OPENSSL_SYS_VMS
@@ -353,6 +362,17 @@ int main(int argc, char *argv[])
        
        CRYPTO_set_locking_callback(lock_dbg_cb);
 
+       /* enable memory leak checking unless explicitly disabled */
+       if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
+               {
+               CRYPTO_malloc_debug_init();
+               CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
+               }
+       else
+               {
+               /* OPENSSL_DEBUG_MEMORY=off */
+               CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
+               }
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
 
        RAND_seed(rnd_seed, sizeof rnd_seed);
@@ -698,6 +718,8 @@ end:
 #ifndef OPENSSL_NO_RSA
        free_tmp_rsa();
 #endif
+       ENGINE_cleanup();
+       CRYPTO_cleanup_all_ex_data();
        ERR_free_strings();
        ERR_remove_state(0);
        EVP_cleanup();