projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rocco Rutte:
[apps/madmutt.git]
/
mutt_ssl_gnutls.c
diff --git
a/mutt_ssl_gnutls.c
b/mutt_ssl_gnutls.c
index
0c4ea8e
..
4028629
100644
(file)
--- a/
mutt_ssl_gnutls.c
+++ b/
mutt_ssl_gnutls.c
@@
-12,6
+12,8
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#ifdef USE_GNUTLS
+
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#ifdef HAVE_GNUTLS_OPENSSL_H
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#ifdef HAVE_GNUTLS_OPENSSL_H
@@
-65,7
+67,7
@@
static int tls_init (void)
return 0;
}
return 0;
}
-int mutt_
gnutls
_socket_setup (CONNECTION * conn)
+int mutt_
ssl
_socket_setup (CONNECTION * conn)
{
if (tls_init () < 0)
return -1;
{
if (tls_init () < 0)
return -1;
@@
-131,7
+133,7
@@
static int tls_socket_open (CONNECTION * conn)
return 0;
}
return 0;
}
-int mutt_
gnutls
_starttls (CONNECTION * conn)
+int mutt_
ssl
_starttls (CONNECTION * conn)
{
if (tls_init () < 0)
return -1;
{
if (tls_init () < 0)
return -1;
@@
-155,11
+157,11
@@
static int tls_negotiate (CONNECTION * conn)
tlssockdata *data;
int err;
tlssockdata *data;
int err;
- data = (tlssockdata *)
safe
_calloc (1, sizeof (tlssockdata));
+ data = (tlssockdata *)
mem
_calloc (1, sizeof (tlssockdata));
conn->sockdata = data;
err = gnutls_certificate_allocate_credentials (&data->xcred);
if (err < 0) {
conn->sockdata = data;
err = gnutls_certificate_allocate_credentials (&data->xcred);
if (err < 0) {
-
FREE
(&conn->sockdata);
+
mem_free
(&conn->sockdata);
mutt_error (_("gnutls_certificate_allocate_credentials: %s"),
gnutls_strerror (err));
mutt_sleep (2);
mutt_error (_("gnutls_certificate_allocate_credentials: %s"),
gnutls_strerror (err));
mutt_sleep (2);
@@
-256,7
+258,7
@@
static int tls_negotiate (CONNECTION * conn)
fail:
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
fail:
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
-
FREE
(&conn->sockdata);
+
mem_free
(&conn->sockdata);
return -1;
}
return -1;
}
@@
-269,7
+271,7
@@
static int tls_socket_close (CONNECTION * conn)
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
gnutls_certificate_free_credentials (data->xcred);
gnutls_deinit (data->state);
-
FREE
(&conn->sockdata);
+
mem_free
(&conn->sockdata);
}
return raw_socket_close (conn);
}
return raw_socket_close (conn);
@@
-304,7
+306,7
@@
static int tls_compare_certificates (const gnutls_datum * peercert)
return 0;
b64_data.size = filestat.st_size + 1;
return 0;
b64_data.size = filestat.st_size + 1;
- b64_data_data = (unsigned char *)
safe
_calloc (1, b64_data.size);
+ b64_data_data = (unsigned char *)
mem
_calloc (1, b64_data.size);
b64_data_data[b64_data.size - 1] = '\0';
b64_data.data = b64_data_data;
b64_data_data[b64_data.size - 1] = '\0';
b64_data.data = b64_data_data;
@@
-319,7
+321,7
@@
static int tls_compare_certificates (const gnutls_datum * peercert)
do {
ret = gnutls_pem_base64_decode_alloc (NULL, &b64_data, &cert);
if (ret != 0) {
do {
ret = gnutls_pem_base64_decode_alloc (NULL, &b64_data, &cert);
if (ret != 0) {
-
FREE
(&b64_data_data);
+
mem_free
(&b64_data_data);
return 0;
}
return 0;
}
@@
-333,7
+335,7
@@
static int tls_compare_certificates (const gnutls_datum * peercert)
if (memcmp (cert.data, peercert->data, cert.size) == 0) {
/* match found */
gnutls_free (cert.data);
if (memcmp (cert.data, peercert->data, cert.size) == 0) {
/* match found */
gnutls_free (cert.data);
-
FREE
(&b64_data_data);
+
mem_free
(&b64_data_data);
return 1;
}
}
return 1;
}
}
@@
-342,7
+344,7
@@
static int tls_compare_certificates (const gnutls_datum * peercert)
} while (ptr != NULL);
/* no match found */
} while (ptr != NULL);
/* no match found */
-
FREE
(&b64_data_data);
+
mem_free
(&b64_data_data);
return 0;
}
return 0;
}
@@
-412,10
+414,10
@@
static int tls_check_stored_hostname (const gnutls_datum * cert,
if (regexec (&preg, linestr, 3, pmatch, 0) == 0) {
linestr[pmatch[1].rm_eo] = '\0';
linestr[pmatch[2].rm_eo] = '\0';
if (regexec (&preg, linestr, 3, pmatch, 0) == 0) {
linestr[pmatch[1].rm_eo] = '\0';
linestr[pmatch[2].rm_eo] = '\0';
- if (
mutt_str
cmp (linestr + pmatch[1].rm_so, hostname) == 0 &&
-
mutt_str
cmp (linestr + pmatch[2].rm_so, buf) == 0) {
+ if (
str_
cmp (linestr + pmatch[1].rm_so, hostname) == 0 &&
+
str_
cmp (linestr + pmatch[2].rm_so, buf) == 0) {
regfree (&preg);
regfree (&preg);
-
FREE
(&linestr);
+
mem_free
(&linestr);
fclose (fp);
return 1;
}
fclose (fp);
return 1;
}
@@
-583,9
+585,9
@@
static int tls_check_certificate (CONNECTION * conn)
/* interactive check from user */
menu = mutt_new_menu ();
menu->max = 25;
/* interactive check from user */
menu = mutt_new_menu ();
menu->max = 25;
- 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++)
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:"),
row = 0;
strfcpy (menu->dialog[row], _("This certificate belongs to:"),
@@
-747,6
+749,7
@@
static int tls_check_certificate (CONNECTION * conn)
menu->help = helpstr;
done = 0;
menu->help = helpstr;
done = 0;
+ set_option (OPTUNBUFFEREDINPUT);
while (!done) {
switch (mutt_menuLoop (menu)) {
case -1: /* abort */
while (!done) {
switch (mutt_menuLoop (menu)) {
case -1: /* abort */
@@
-789,7
+792,10
@@
static int tls_check_certificate (CONNECTION * conn)
break;
}
}
break;
}
}
+ unset_option (OPTUNBUFFEREDINPUT);
mutt_menuDestroy (&menu);
gnutls_x509_crt_deinit (cert);
return (done == 2);
}
mutt_menuDestroy (&menu);
gnutls_x509_crt_deinit (cert);
return (done == 2);
}
+
+#endif /* USE_GNUTLS */