X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=mutt_ssl.c;h=804183cf0138cea306165d69609b8638ffbab598;hp=870ab8936d0f22b6b4b2f1861f79b6021141637c;hb=3e611c4b53a33408955152e1c9336f8643ea096e;hpb=a8477ebaa09990b3688164cbe5cf661c4189541d diff --git a/mutt_ssl.c b/mutt_ssl.c index 870ab89..804183c 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -11,24 +11,25 @@ # include "config.h" #endif +#ifdef USE_SSL + #include #include #include #include -#undef _ - #include +#include +#include +#include + #include "mutt.h" #include "mutt_socket.h" #include "mutt_menu.h" #include "mutt_curses.h" #include "mutt_ssl.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/debug.h" #if OPENSSL_VERSION_NUMBER >= 0x00904000L @@ -62,7 +63,7 @@ typedef struct _sslsockdata { } sslsockdata; /* local prototypes */ -int ssl_init (void); +static int ssl_init (void); static int add_entropy (const char *file); static int ssl_socket_read (CONNECTION * conn, char *buf, size_t len); static int ssl_socket_write (CONNECTION * conn, const char *buf, size_t len); @@ -84,7 +85,7 @@ int mutt_ssl_starttls (CONNECTION * conn) if (ssl_init ()) goto bail; - ssldata = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata)); + ssldata = p_new(sslsockdata, 1); /* 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 +119,11 @@ int mutt_ssl_starttls (CONNECTION * conn) return 0; bail_ssl: - FREE (&ssldata->ssl); + p_delete(&ssldata->ssl); bail_ctx: - FREE (&ssldata->ctx); + p_delete(&ssldata->ctx); bail_ssldata: - FREE (&ssldata); + p_delete(&ssldata); bail: return -1; } @@ -137,7 +138,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 +220,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 +257,7 @@ static int ssl_socket_open (CONNECTION * conn) if (raw_socket_open (conn) < 0) return -1; - data = (sslsockdata *) safe_calloc (1, sizeof (sslsockdata)); + data = p_new(sslsockdata, 1); conn->sockdata = data; data->ctx = SSL_CTX_new (SSLv23_client_method ()); @@ -348,7 +349,7 @@ static int ssl_socket_close (CONNECTION * conn) #endif SSL_free (data->ssl); SSL_CTX_free (data->ctx); - FREE (&conn->sockdata); + p_delete(&conn->sockdata); } return raw_socket_close (conn); @@ -415,7 +416,7 @@ static char *x509_get_part (char *line, const char *ndx) c = strstr (line, ndx); if (c) { - c += str_len (ndx); + c += m_strlen(ndx); c2 = strchr (c, '/'); if (c2) *c2 = '\0'; @@ -582,9 +583,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 = p_new(char *, menu->max); for (i = 0; i < menu->max; i++) - menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char)); + menu->dialog[i] = p_new(char, SHORT_STRING); row = 0; strfcpy (menu->dialog[row], _("This certificate belongs to:"), @@ -707,3 +708,5 @@ static int ssl_passwd_cb (char *buf, int size, int rwflag, void *userdata) return snprintf (buf, size, "%s", account->pass); } + +#endif /* USE_SSL */