#include "mutt_crypt.h"
#include "mutt_menu.h"
#include "mutt_curses.h"
+#include "ascii.h"
+#include "handler.h"
+#include "enter.h"
#include "mime.h"
#include "copy.h"
#include "pager.h"
+#include "recvattach.h"
#include "sort.h"
#include "lib/mem.h"
{
char *tstr;
- tstr = safe_malloc (len + 1);
+ tstr = mem_malloc (len + 1);
memcpy (tstr, buf, len);
tstr[len] = 0;
mutt_convert_string (&tstr, "utf-8", Charset, M_ICONV_HOOK_FROM);
fputs (tstr, fp);
- FREE (&tstr);
+ mem_free (&tstr);
}
{
crypt_key_t *k;
- k = safe_calloc (1, sizeof *k);
+ k = mem_calloc (1, sizeof *k);
k->kobj = key->kobj;
gpgme_key_ref (key->kobj);
k->idx = key->idx;
while (*keylist) {
crypt_key_t *k = (*keylist)->next;
- FREE (&k);
+ mem_free (&k);
*keylist = k;
}
}
err = gpgme_get_key (context, buf, &key, 0);
if (!err) {
- safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+ mem_realloc (&rset, sizeof (*rset) * (rset_n + 1));
rset[rset_n++] = key;
}
else {
mutt_error (_("error adding recipient `%s': %s\n"),
buf, gpgme_strerror (err));
- FREE (&rset);
+ mem_free (&rset);
return NULL;
}
}
}
/* NULL terminate. */
- safe_realloc (&rset, sizeof (*rset) * (rset_n + 1));
+ mem_realloc (&rset, sizeof (*rset) * (rset_n + 1));
rset[rset_n++] = NULL;
if (context)
convert_to_7bit (a);
plaintext = body_to_data_object (a, 0);
if (!plaintext) {
- FREE (&rset);
+ mem_free (&rset);
return NULL;
}
outfile = encrypt_gpgme_object (plaintext, rset, 0, sign);
gpgme_data_release (plaintext);
- FREE (&rset);
+ mem_free (&rset);
if (!outfile)
return NULL;
plaintext = body_to_data_object (a, 0);
if (!plaintext) {
- FREE (&rset);
+ mem_free (&rset);
return NULL;
}
outfile = encrypt_gpgme_object (plaintext, rset, 1, 0);
gpgme_data_release (plaintext);
- FREE (&rset);
+ mem_free (&rset);
if (!outfile)
return NULL;
return;
is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
- buf = safe_malloc (str_len (prefix) + str_len (s) * 4 + 2);
+ buf = mem_malloc (str_len (prefix) + str_len (s) * 4 + 2);
strcpy (buf, prefix); /* __STRCPY_CHECKED__ */
p = buf + str_len (buf);
if (is_pgp && str_len (s) == 40) { /* PGP v4 style formatted. */
*p++ = '\n';
*p = 0;
state_attach_puts (buf, state);
- FREE (&buf);
+ mem_free (&buf);
}
/* Show the valididy of a key used for one signature. */
if (!fname)
return;
unlink (fname);
- FREE (&fname);
+ mem_free (&fname);
fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM);
/* Support for classic_application/pgp */
-void pgp_gpgme_application_handler (BODY * m, STATE * s)
+int pgp_gpgme_application_handler (BODY * m, STATE * s)
{
int needpass = -1, pgp_keyblock = 0;
int clearsign = 0;
char buf[HUGE_STRING];
FILE *pgpout = NULL;
- gpgme_error_t err;
+ gpgme_error_t err = 0;
gpgme_data_t armored_data = NULL;
short maybe_goodsig = 1;
}
else {
unlink (tmpfname);
- FREE (&tmpfname);
+ mem_free (&tmpfname);
}
}
gpgme_release (ctx);
if (needpass == -1) {
state_attach_puts (_("[-- Error: could not find beginning"
" of PGP message! --]\n\n"), s);
- return;
+ return (-1);
}
debug_print (2, ("Leaving pgp_application_pgp handler\n"));
+ return (err);
}
/*
*/
/* MIME handler for pgp/mime encrypted messages. */
-void pgp_gpgme_encrypted_handler (BODY * a, STATE * s)
+int pgp_gpgme_encrypted_handler (BODY * a, STATE * s)
{
char tempfile[_POSIX_PATH_MAX];
FILE *fpout;
BODY *tattach;
BODY *orig_body = a;
int is_signed;
+ int rc = 0;
debug_print (2, ("Entering pgp_encrypted handler\n"));
a = a->parts;
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"),
s);
- return;
+ return (-1);
}
/* Move forward to the application/pgp-encrypted body. */
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: could not create temporary file! "
"--]\n"), s);
- return;
+ return (-1);
}
tattach = decrypt_part (a, s, fpout, 0, &is_signed);
if (s->flags & M_DISPLAY)
state_attach_puts (is_signed ?
_
- ("[-- The following data is PGP/MIME signed and encrypted --]\n\n")
- :
- _
- ("[-- The following data is PGP/MIME encrypted --]\n\n"),
- s);
+ ("[-- The following data is PGP/MIME signed and encrypted --]\n\n") :
+ _("[-- The following data is PGP/MIME encrypted --]\n\n"), s);
{
FILE *savefp = s->fpin;
s->fpin = fpout;
- mutt_body_handler (tattach, s);
+ rc = mutt_body_handler (tattach, s);
s->fpin = savefp;
}
fclose (fpout);
mutt_unlink (tempfile);
debug_print (2, ("Leaving pgp_encrypted handler\n"));
+ return (rc);
}
/* Support for application/smime */
-void smime_gpgme_application_handler (BODY * a, STATE * s)
+int smime_gpgme_application_handler (BODY * a, STATE * s)
{
char tempfile[_POSIX_PATH_MAX];
FILE *fpout;
BODY *tattach;
int is_signed;
-
+ int rc = 0;
debug_print (2, ("Entering smime_encrypted handler\n"));
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: could not create temporary file! "
"--]\n"), s);
- return;
+ return (-1);
}
tattach = decrypt_part (a, s, fpout, 1, &is_signed);
if (s->flags & M_DISPLAY)
state_attach_puts (is_signed ?
- _("[-- The following data is S/MIME signed --]\n\n")
- :
- _
- ("[-- The following data is S/MIME encrypted --]\n\n"),
- s);
+ _("[-- The following data is S/MIME signed --]\n\n") :
+ _("[-- The following data is S/MIME encrypted --]\n\n"), s);
{
FILE *savefp = s->fpin;
s->fpin = fpout;
- mutt_body_handler (tattach, s);
+ rc = mutt_body_handler (tattach, s);
s->fpin = savefp;
}
fclose (fpout);
mutt_unlink (tempfile);
debug_print (2, ("Leaving smime_encrypted handler\n"));
+ return (rc);
}
n = s - string;
if (!n)
return NULL; /* empty key */
- array->key = safe_malloc (n + 1);
+ array->key = mem_malloc (n + 1);
p = (unsigned char *) array->key;
memcpy (p, string, n); /* fixme: trim trailing spaces */
p[n] = 0;
if (!n || (n & 1))
return NULL; /* empty or odd number of digits */
n /= 2;
- p = safe_malloc (n + 1);
+ p = mem_malloc (n + 1);
array->value = (char *) p;
for (s1 = string; n; s1 += 2, n--)
*p++ = xtoi_2 (s1);
n++;
}
- p = safe_malloc (n + 1);
+ p = mem_malloc (n + 1);
array->value = (char *) p;
for (s = string; n; s++, n--) {
if (*s == '\\') {
int i;
arraysize = 7; /* C,ST,L,O,OU,CN,email */
- array = safe_malloc ((arraysize + 1) * sizeof *array);
+ array = mem_malloc ((arraysize + 1) * sizeof *array);
arrayidx = 0;
while (*string) {
while (*string == ' ')
struct dn_array_s *a2;
arraysize += 5;
- a2 = safe_malloc ((arraysize + 1) * sizeof *array);
+ a2 = mem_malloc ((arraysize + 1) * sizeof *array);
for (i = 0; i < arrayidx; i++) {
a2[i].key = array[i].key;
a2[i].value = array[i].value;
}
- FREE (&array);
+ mem_free (&array);
array = a2;
}
array[arrayidx].key = NULL;
failure:
for (i = 0; i < arrayidx; i++) {
- FREE (&array[i].key);
- FREE (&array[i].value);
+ mem_free (&array[i].key);
+ mem_free (&array[i].value);
}
- FREE (&array);
+ mem_free (&array);
return NULL;
}
else {
print_dn_parts (fp, dn);
for (i = 0; dn[i].key; i++) {
- FREE (&dn[i].key);
- FREE (&dn[i].value);
+ mem_free (&dn[i].key);
+ mem_free (&dn[i].value);
}
- FREE (&dn);
+ mem_free (&dn);
}
}
}
continue;
s = uid->uid;
- fprintf (fp, "%s ......: ", idx ? _(" aka") : _("Name"));
+ fputs (idx ? _(" aka ......: ") :_("Name ......: "), fp);
+
if (uid->invalid) {
fputs (_("[Invalid]"), fp);
putc (' ', fp);
#else
strftime (shortbuf, sizeof shortbuf, "%c", tm);
#endif
- fprintf (fp, "Valid From : %s\n", shortbuf);
+ fprintf (fp, _("Valid From : %s\n"), shortbuf);
}
if (key->subkeys && (key->subkeys->expires > 0)) {
#else
strftime (shortbuf, sizeof shortbuf, "%c", tm);
#endif
- fprintf (fp, "Valid To ..: %s\n", shortbuf);
+ fprintf (fp, _("Valid To ..: %s\n"), shortbuf);
}
if (key->subkeys)
if (key->subkeys)
aval = key->subkeys->length;
- fprintf (fp, "Key Type ..: %s, %lu bit %s\n", s2, aval, s);
+ fprintf (fp, _("Key Type ..: %s, %lu bit %s\n"), s2, aval, s);
- fprintf (fp, "Key Usage .: ");
+ fprintf (fp, _("Key Usage .: "));
delim = "";
if (key_check_cap (key, KEY_CAP_CAN_ENCRYPT)) {
fprintf (fp, "%s%s", delim, _("encryption"));
- delim = ", ";
+ delim = _(", ");
}
if (key_check_cap (key, KEY_CAP_CAN_SIGN)) {
fprintf (fp, "%s%s", delim, _("signing"));
- delim = ", ";
+ delim = _(", ");
}
if (key_check_cap (key, KEY_CAP_CAN_CERTIFY)) {
fprintf (fp, "%s%s", delim, _("certification"));
- delim = ", ";
+ delim = _(", ");
}
putc ('\n', fp);
if (key->issuer_serial) {
s = key->issuer_serial;
if (s)
- fprintf (fp, "Serial-No .: 0x%s\n", s);
+ fprintf (fp, _("Serial-No .: 0x%s\n"), s);
}
if (key->issuer_name) {
s = key->issuer_name;
if (s) {
- fprintf (fp, "Issued By .: ");
+ fprintf (fp, _("Issued By .: "));
parse_and_print_user_id (fp, s);
putc ('\n', fp);
}
putc ('\n', fp);
if (str_len (s) == 16)
s += 8; /* display only the short keyID */
- fprintf (fp, "Subkey ....: 0x%s", s);
+ fprintf (fp, _("Subkey ....: 0x%s"), s);
if (subkey->revoked) {
putc (' ', fp);
fputs (_("[Revoked]"), fp);
#else
strftime (shortbuf, sizeof shortbuf, "%c", tm);
#endif
- fprintf (fp, "Valid From : %s\n", shortbuf);
+ fprintf (fp, _("Valid From : %s\n"), shortbuf);
}
if (subkey->expires > 0) {
#else
strftime (shortbuf, sizeof shortbuf, "%c", tm);
#endif
- fprintf (fp, "Valid To ..: %s\n", shortbuf);
+ fprintf (fp, _("Valid To ..: %s\n"), shortbuf);
}
if (subkey)
else
aval = 0;
- fprintf (fp, "Key Type ..: %s, %lu bit %s\n", "PGP", aval, s);
+ fprintf (fp, _("Key Type ..: %s, %lu bit %s\n"), "PGP", aval, s);
- fprintf (fp, "Key Usage .: ");
+ fprintf (fp, _("Key Usage .: "));
delim = "";
if (subkey->can_encrypt) {
fprintf (fp, "%s%s", delim, _("encryption"));
- delim = ", ";
+ delim = _(", ");
}
if (subkey->can_sign) {
fprintf (fp, "%s%s", delim, _("signing"));
- delim = ", ";
+ delim = _(", ");
}
if (subkey->can_certify) {
fprintf (fp, "%s%s", delim, _("certification"));
- delim = ", ";
+ delim = _(", ");
}
putc ('\n', fp);
}
n++; /* delimiter or end of string */
}
n++; /* make sure to allocate at least one byte */
- pattern = p = safe_calloc (1, n);
+ pattern = p = mem_calloc (1, n);
for (l = list; l; l = l->next) {
s = l->data;
if (*s) {
err = gpgme_new (&ctx);
if (err) {
mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err));
- FREE (&pattern);
+ mem_free (&pattern);
return NULL;
}
if (!n)
goto no_pgphints;
- patarr = safe_calloc (n + 1, sizeof *patarr);
+ patarr = mem_calloc (n + 1, sizeof *patarr);
for (l = hints, n = 0; l; l = l->next) {
if (l->data && *l->data)
patarr[n++] = str_dup (l->data);
patarr[n] = NULL;
err = gpgme_op_keylist_ext_start (ctx, (const char **) patarr, secret, 0);
for (n = 0; patarr[n]; n++)
- FREE (&patarr[n]);
- FREE (&patarr);
+ mem_free (&patarr[n]);
+ mem_free (&patarr);
if (err) {
mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err));
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return NULL;
}
#endif /* DISABLED code */
for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) {
- k = safe_calloc (1, sizeof *k);
+ k = mem_calloc (1, sizeof *k);
k->kobj = key;
k->idx = idx;
k->uid = uid->uid;
if (err) {
mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err));
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return NULL;
}
flags |= KEYFLAG_CANSIGN;
for (idx = 0, uid = key->uids; uid; idx++, uid = uid->next) {
- k = safe_calloc (1, sizeof *k);
+ k = mem_calloc (1, sizeof *k);
k->kobj = key;
k->idx = idx;
k->uid = uid->uid;
}
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return db;
}
hints = mutt_add_list (hints, t);
}
- FREE (&scratch);
+ mem_free (&scratch);
return hints;
}
if (i == keymax) {
keymax += 20;
- safe_realloc (&key_table, sizeof (crypt_key_t *) * keymax);
+ mem_realloc (&key_table, sizeof (crypt_key_t *) * keymax);
}
key_table[i++] = k;
}
mutt_menuDestroy (&menu);
- FREE (&key_table);
+ mem_free (&key_table);
set_option (OPTNEEDREDRAW);
if (l)
str_replace (&l->dflt, resp);
else {
- l = safe_malloc (sizeof (struct crypt_cache));
+ l = mem_malloc (sizeof (struct crypt_cache));
l->next = id_defaults;
id_defaults = l;
l->what = str_dup (whatfor);
}
}
else if (r == -1) {
- FREE (&keylist);
+ mem_free (&keylist);
rfc822_free_address (&tmp);
rfc822_free_address (&addr);
return NULL;
app,
#endif
&forced_valid)) == NULL) {
- FREE (&keylist);
+ mem_free (&keylist);
rfc822_free_address (&tmp);
rfc822_free_address (&addr);
return NULL;
#endif
keylist_size += str_len (s) + 4 + 1;
- safe_realloc (&keylist, keylist_size);
+ mem_realloc (&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */
keylist_used ? " " : "", s, forced_valid ? "!" : "");
}