Rocco Rutte:
[apps/madmutt.git] / mutt_ssl.c
index 870ab89..f73cca7 100644 (file)
@@ -11,6 +11,8 @@
 # include "config.h"
 #endif
 
+#ifdef USE_SSL
+
 #include <openssl/ssl.h>
 #include <openssl/x509.h>
 #include <openssl/err.h>
@@ -84,7 +86,7 @@ int mutt_ssl_starttls (CONNECTION * conn)
   if (ssl_init ())
     goto bail;
 
-  ssldata = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata));
+  ssldata = (sslsockdata *) mem_calloc (1, sizeof (sslsockdata));
   /* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS. */
   if (!(ssldata->ctx = SSL_CTX_new (TLSv1_client_method ()))) {
     debug_print (1, ("Error allocating SSL_CTX\n"));
@@ -118,11 +120,11 @@ int mutt_ssl_starttls (CONNECTION * conn)
   return 0;
 
 bail_ssl:
-  FREE (&ssldata->ssl);
+  mem_free (&ssldata->ssl);
 bail_ctx:
-  FREE (&ssldata->ctx);
+  mem_free (&ssldata->ctx);
 bail_ssldata:
-  FREE (&ssldata);
+  mem_free (&ssldata);
 bail:
   return -1;
 }
@@ -137,7 +139,7 @@ bail:
  * versions also. (That's the reason for the ugly #ifdefs and macros,
  * otherwise I could have simply #ifdef'd the whole ssl_init funcion)
  */
-int ssl_init (void)
+static int ssl_init (void)
 {
   char path[_POSIX_PATH_MAX];
   static unsigned char init_complete = 0;
@@ -219,7 +221,7 @@ static int ssl_socket_open_err (CONNECTION * conn)
 }
 
 
-int ssl_socket_setup (CONNECTION * conn)
+int mutt_ssl_socket_setup (CONNECTION * conn)
 {
   if (ssl_init () < 0) {
     conn->conn_open = ssl_socket_open_err;
@@ -256,7 +258,7 @@ static int ssl_socket_open (CONNECTION * conn)
   if (raw_socket_open (conn) < 0)
     return -1;
 
-  data = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata));
+  data = (sslsockdata *) mem_calloc (1, sizeof (sslsockdata));
   conn->sockdata = data;
 
   data->ctx = SSL_CTX_new (SSLv23_client_method ());
@@ -348,7 +350,7 @@ static int ssl_socket_close (CONNECTION * conn)
 #endif
     SSL_free (data->ssl);
     SSL_CTX_free (data->ctx);
-    FREE (&conn->sockdata);
+    mem_free (&conn->sockdata);
   }
 
   return raw_socket_close (conn);
@@ -582,9 +584,9 @@ static int ssl_check_certificate (sslsockdata * data)
   /* interactive check from user */
   menu = mutt_new_menu ();
   menu->max = 19;
-  menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
+  menu->dialog = (char **) mem_calloc (1, menu->max * sizeof (char *));
   for (i = 0; i < menu->max; i++)
-    menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
+    menu->dialog[i] = (char *) mem_calloc (1, SHORT_STRING * sizeof (char));
 
   row = 0;
   strfcpy (menu->dialog[row], _("This certificate belongs to:"),
@@ -707,3 +709,5 @@ static int ssl_passwd_cb (char *buf, int size, int rwflag, void *userdata)
 
   return snprintf (buf, size, "%s", account->pass);
 }
+
+#endif /* USE_SSL */