#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"
#include "lib/intl.h"
#include "lib/str.h"
+#include "lib/debug.h"
#include <sys/wait.h>
#include <string.h>
* General helper functions.
*/
-/* return true when S pints to a didgit or letter. */
+/* return true when S points to a didgit or letter. */
static int digit_or_letter (const unsigned char *s)
{
- return ((*s >= '0' && *s < '9')
+ return ((*s >= '0' && *s <= '9')
|| (*s >= 'A' && *s <= 'Z')
|| (*s >= 'a' && *s <= 'z'));
}
{
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);
}
if (k->kobj && k->kobj->subkeys) {
s = k->kobj->subkeys->keyid;
- if ((!option (OPTPGPLONGIDS)) && (safe_strlen (s) == 16))
+ if ((!option (OPTPGPLONGIDS)) && (str_len (s) == 16))
/* Return only the short keyID. */
s += 8;
}
{
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;
}
}
rv |= CRYPT_KV_STRONGID;
if (addr->mailbox && u_addr->mailbox
- && safe_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
+ && str_casecmp (addr->mailbox, u_addr->mailbox) == 0)
rv |= CRYPT_KV_ADDR;
if (addr->personal && u_addr->personal
- && safe_strcasecmp (addr->personal, u_addr->personal) == 0)
+ && str_casecmp (addr->personal, u_addr->personal) == 0)
rv |= CRYPT_KV_STRING;
return rv;
err = gpgme_new (&ctx);
if (err) {
- mutt_error ("error creating gpgme context: %s\n", gpgme_strerror (err));
+ mutt_error (_("error creating gpgme context: %s\n"), gpgme_strerror (err));
sleep (2);
mutt_exit (1);
}
if (for_smime) {
err = gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
if (err) {
- mutt_error ("error enabling CMS protocol: %s\n", gpgme_strerror (err));
+ mutt_error (_("error enabling CMS protocol: %s\n"), gpgme_strerror (err));
sleep (2);
mutt_exit (1);
}
err = gpgme_data_new (&data);
if (err) {
- mutt_error ("error creating gpgme data object: %s\n",
+ mutt_error (_("error creating gpgme data object: %s\n"),
gpgme_strerror (err));
sleep (2);
mutt_exit (1);
}
unlink (tempfile);
if (err) {
- mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+ mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err));
return NULL;
}
err = gpgme_data_new_from_filepart (&data, NULL, fp, offset, length);
if (err) {
- mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+ mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err));
return NULL;
}
err = ((gpgme_data_seek (data, 0, SEEK_SET) == -1)
? gpgme_error_from_errno (errno) : 0);
if (err) {
- mutt_error ("error rewinding data object: %s\n", gpgme_strerror (err));
+ mutt_error (_("error rewinding data object: %s\n"), gpgme_strerror (err));
return -1;
}
}
}
if (nread == -1) {
- mutt_error ("error reading data object: %s\n", strerror (errno));
+ mutt_error (_("error reading data object: %s\n"), strerror (errno));
return -1;
}
return 0;
else
fclose (fp);
if (nread == -1) {
- mutt_error ("error reading data object: %s\n", gpgme_strerror (err));
+ mutt_error (_("error reading data object: %s\n"), gpgme_strerror (err));
unlink (tempfile);
fclose (fp);
return NULL;
}
if (ret_fp)
*ret_fp = fp;
- return safe_strdup (tempfile);
+ return str_dup (tempfile);
}
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",
+ 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)
gpgme_key_release (key);
gpgme_key_release (key2);
gpgme_release (listctx);
- mutt_error (_("ambiguous specfication of secret key `%s'\n"), signid);
+ mutt_error (_("ambiguous specification of secret key `%s'\n"), signid);
return -1;
}
gpgme_op_keylist_end (listctx);
plaintext, ciphertext);
mutt_need_hard_redraw ();
if (err) {
- mutt_error ("error encrypting data: %s\n", gpgme_strerror (err));
+ mutt_error (_("error encrypting data: %s\n"), gpgme_strerror (err));
gpgme_data_release (ciphertext);
gpgme_release (ctx);
return NULL;
if (err) {
gpgme_data_release (signature);
gpgme_release (ctx);
- mutt_error ("error signing data: %s\n", gpgme_strerror (err));
+ mutt_error (_("error signing data: %s\n"), gpgme_strerror (err));
return NULL;
}
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("signed");
+ t->subtype = str_dup ("signed");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t = t->parts->next;
t->type = TYPEAPPLICATION;
if (use_smime) {
- t->subtype = safe_strdup ("pkcs7-signature");
+ t->subtype = str_dup ("pkcs7-signature");
mutt_set_parameter ("name", "smime.p7s", &t->parameter);
t->encoding = ENCBASE64;
t->use_disp = 1;
t->disposition = DISPATTACH;
- t->d_filename = safe_strdup ("smime.p7s");
+ t->d_filename = str_dup ("smime.p7s");
}
else {
- t->subtype = safe_strdup ("pgp-signature");
+ t->subtype = str_dup ("pgp-signature");
t->use_disp = 0;
t->disposition = DISPINLINE;
t->encoding = ENC7BIT;
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;
t = mutt_new_body ();
t->type = TYPEMULTIPART;
- t->subtype = safe_strdup ("encrypted");
+ t->subtype = str_dup ("encrypted");
t->encoding = ENC7BIT;
t->use_disp = 0;
t->disposition = DISPINLINE;
t->parts = mutt_new_body ();
t->parts->type = TYPEAPPLICATION;
- t->parts->subtype = safe_strdup ("pgp-encrypted");
+ t->parts->subtype = str_dup ("pgp-encrypted");
t->parts->encoding = ENC7BIT;
t->parts->next = mutt_new_body ();
t->parts->next->type = TYPEAPPLICATION;
- t->parts->next->subtype = safe_strdup ("octet-stream");
+ t->parts->next->subtype = str_dup ("octet-stream");
t->parts->next->encoding = ENC7BIT;
t->parts->next->filename = outfile;
t->parts->next->use_disp = 1;
t->parts->next->disposition = DISPINLINE;
t->parts->next->unlink = 1; /* delete after sending the message */
- t->parts->next->d_filename = safe_strdup ("msg.asc"); /* non pgp/mime
+ t->parts->next->d_filename = str_dup ("msg.asc"); /* non pgp/mime
can save */
return t;
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;
t = mutt_new_body ();
t->type = TYPEAPPLICATION;
- t->subtype = safe_strdup ("pkcs7-mime");
+ t->subtype = str_dup ("pkcs7-mime");
mutt_set_parameter ("name", "smime.p7m", &t->parameter);
mutt_set_parameter ("smime-type", "enveloped-data", &t->parameter);
t->encoding = ENCBASE64; /* The output of OpenSSL SHOULD be binary */
t->use_disp = 1;
t->disposition = DISPATTACH;
- t->d_filename = safe_strdup ("smime.p7m");
+ t->d_filename = str_dup ("smime.p7m");
t->filename = outfile;
t->unlink = 1; /*delete after sending the message */
t->parts = 0;
gpgme_signature_t sig;
unsigned int i;
- state_attach_puts (_("A system error occured"), s);
+ state_attach_puts (_("A system error occurred"), s);
/* Try to figure out some more detailed system error information. */
result = gpgme_op_verify_result (ctx);
state_attach_puts (": ", s);
if (t0)
state_attach_puts (t0, s);
- if (t1 && !(t0 && !safe_strcmp (t0, t1))) {
+ if (t1 && !(t0 && !str_cmp (t0, t1))) {
if (t0)
state_attach_puts (",", s);
state_attach_puts (t1, s);
return;
is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP);
- buf = safe_malloc (safe_strlen (prefix) + safe_strlen (s) * 4 + 2);
+ buf = mem_malloc (str_len (prefix) + str_len (s) * 4 + 2);
strcpy (buf, prefix); /* __STRCPY_CHECKED__ */
- p = buf + safe_strlen (buf);
- if (is_pgp && safe_strlen (s) == 40) { /* PGP v4 style formatted. */
+ p = buf + str_len (buf);
+ if (is_pgp && str_len (s) == 40) { /* PGP v4 style formatted. */
for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
*p++ = s[0];
*p++ = s[1];
*p++ = '\n';
*p = 0;
state_attach_puts (buf, state);
- FREE (&buf);
+ mem_free (&buf);
}
/* Show the valididy of a key used for one signature. */
err = gpgme_data_new_from_file (&message, tempfile, 1);
if (err) {
gpgme_data_release (signature);
- mutt_error ("error allocating data object: %s\n", gpgme_strerror (err));
+ mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err));
return -1;
}
ctx = create_gpgme_context (is_smime);
if (notation->value) {
state_attach_puts (notation->value, s);
if (!(*notation->value
- && (notation->value[safe_strlen (notation->value) - 1] ==
+ && (notation->value[str_len (notation->value) - 1] ==
'\n')))
state_attach_puts ("\n", s);
}
gpgme_release (ctx);
state_attach_puts (_("[-- End signature information --]\n\n"), s);
- dprint (1, (debugfile, "verify_one: returning %d.\n", badsig));
+ debug_print (1, ("returning %d.\n", badsig));
return badsig ? 1 : anywarn ? 2 : 0;
}
}
while (fgets (buf, sizeof (buf), tfp)) {
- if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
- if (!safe_strcmp ("MESSAGE-----\n", buf + 15))
+ if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!str_cmp ("MESSAGE-----\n", buf + 15))
enc = 1;
- else if (!safe_strcmp ("SIGNED MESSAGE-----\n", buf + 15))
+ else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15))
sgn = 1;
}
}
if (!fname)
return;
unlink (fname);
- FREE (&fname);
+ mem_free (&fname);
fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM);
continue;
}
- if (!safe_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
+ if (!str_cmp (buf, "-----BEGIN PGP SIGNATURE-----\n"))
break;
if (armor_header) {
/* 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;
char body_charset[STRING]; /* Only used for clearsigned messages. */
- dprint (2, (debugfile, "Entering pgp_application_pgp handler\n"));
+ debug_print (2, ("Entering pgp_application_pgp handler\n"));
/* For clearsigned messages we won't be able to get a character set
but we know that this may only be text thus we assume Latin-1
break;
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on safe_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
- if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) {
+ if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) {
clearsign = 0;
start_pos = last_pos;
- if (!safe_strcmp ("MESSAGE-----\n", buf + 15))
+ if (!str_cmp ("MESSAGE-----\n", buf + 15))
needpass = 1;
- else if (!safe_strcmp ("SIGNED MESSAGE-----\n", buf + 15)) {
+ else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15)) {
clearsign = 1;
needpass = 0;
}
else if (!option (OPTDONTHANDLEPGPKEYS) &&
- !safe_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) {
+ !str_cmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) {
needpass = 0;
pgp_keyblock = 1;
}
/* Copy PGP material to an data container */
armored_data = create_gpgme_data ();
- gpgme_data_write (armored_data, buf, safe_strlen (buf));
+ gpgme_data_write (armored_data, buf, str_len (buf));
while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) {
offset = ftell (s->fpin);
- bytes -= (offset - last_pos); /* don't rely on safe_strlen(buf) */
+ bytes -= (offset - last_pos); /* don't rely on str_len(buf) */
last_pos = offset;
- gpgme_data_write (armored_data, buf, safe_strlen (buf));
+ gpgme_data_write (armored_data, buf, str_len (buf));
- if ((needpass && !safe_strcmp ("-----END PGP MESSAGE-----\n", buf))
+ if ((needpass && !str_cmp ("-----END PGP MESSAGE-----\n", buf))
|| (!needpass
- && (!safe_strcmp ("-----END PGP SIGNATURE-----\n", buf)
- || !safe_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
+ && (!str_cmp ("-----END PGP SIGNATURE-----\n", buf)
+ || !str_cmp ("-----END PGP PUBLIC KEY BLOCK-----\n",
buf))))
break;
}
}
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);
}
- dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n"));
+ 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;
- dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
+ debug_print (2, ("Entering pgp_encrypted handler\n"));
a = a->parts;
if (!a || a->type != TYPEAPPLICATION || !a->subtype
|| ascii_strcasecmp ("pgp-encrypted", a->subtype)
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);
- dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
+ 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;
-
- dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
+ debug_print (2, ("Entering smime_encrypted handler\n"));
a->warnsig = 0;
mutt_mktemp (tempfile);
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);
- dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
+ debug_print (2, ("Leaving smime_encrypted handler\n"));
+ return (rc);
}
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = str_casecmp ((*s)->uid, (*t)->uid)))
return r > 0;
else
- return safe_strcasecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
+ return str_casecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
}
static int crypt_compare_address (const void *a, const void *b)
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = safe_strcasecmp (crypt_keyid (*s), crypt_keyid (*t))))
+ if ((r = str_casecmp (crypt_keyid (*s), crypt_keyid (*t))))
return r > 0;
else
- return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return str_casecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_keyid (const void *a, const void *b)
if (ts < tt)
return 0;
- return safe_strcasecmp ((*s)->uid, (*t)->uid) > 0;
+ return str_casecmp ((*s)->uid, (*t)->uid) > 0;
}
static int crypt_compare_date (const void *a, const void *b)
if (ts < tt)
return 0;
- if ((r = safe_strcasecmp ((*s)->uid, (*t)->uid)))
+ if ((r = str_casecmp ((*s)->uid, (*t)->uid)))
return r > 0;
- return (safe_strcasecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
+ return (str_casecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
}
static int crypt_compare_trust (const void *a, const void *b)
int any = 0;
for (; dn->key; dn++) {
- if (!safe_strcmp (dn->key, key)) {
+ if (!str_cmp (dn->key, key)) {
if (any)
fputs (" + ", fp);
- print_utf8 (fp, dn->value, safe_strlen (dn->value));
+ print_utf8 (fp, dn->value, str_len (dn->value));
any = 1;
}
}
/* now print the rest without any specific ordering */
for (; dn->key; dn++) {
for (i = 0; stdpart[i]; i++) {
- if (!safe_strcmp (dn->key, stdpart[i]))
+ if (!str_cmp (dn->key, stdpart[i]))
break;
}
if (!stdpart[i]) {
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);
}
if (is_pgp)
- print_utf8 (fp, s, safe_strlen (s));
+ print_utf8 (fp, s, str_len (s));
else
parse_and_print_user_id (fp, s);
putc ('\n', 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->subkeys) {
s = key->subkeys->fpr;
fputs (_("Fingerprint: "), fp);
- if (is_pgp && safe_strlen (s) == 40) {
+ if (is_pgp && str_len (s) == 40) {
for (i = 0; *s && s[1] && s[2] && s[3] && s[4]; s += 4, i++) {
putc (*s, fp);
putc (s[1], 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);
}
s = subkey->keyid;
putc ('\n', fp);
- if (safe_strlen (s) == 16)
+ 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);
}
mutt_mktemp (tempfile);
if (!(fp = safe_fopen (tempfile, "w"))) {
- mutt_perror _("Can't create temporary file");
+ mutt_perror (_("Can't create temporary file"));
return;
}
k = key->kobj;
gpgme_key_ref (k);
- while ((s = k->chain_id) && k->subkeys && safe_strcmp (s, k->subkeys->fpr)) {
+ while ((s = k->chain_id) && k->subkeys && str_cmp (s, k->subkeys->fpr)) {
putc ('\n', fp);
err = gpgme_op_keylist_start (listctx, s, 0);
gpgme_key_release (k);
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);
+ mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err));
+ 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++] = safe_strdup (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));
+ 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 (gpg_err_code (err) != GPG_ERR_EOF)
- mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
+ mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror (err));
gpgme_op_keylist_end (ctx);
no_pgphints:
;
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
err = gpgme_op_keylist_start (ctx, pattern, 0);
if (err) {
- mutt_error ("gpgme_op_keylist_start failed: %s", gpgme_strerror (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;
}
}
if (gpg_err_code (err) != GPG_ERR_EOF)
- mutt_error ("gpgme_op_keylist_next failed: %s", gpgme_strerror (err));
+ mutt_error (_("gpgme_op_keylist_next failed: %s"), gpgme_strerror (err));
gpgme_op_keylist_end (ctx);
}
gpgme_release (ctx);
- FREE (&pattern);
+ mem_free (&pattern);
return db;
}
char *scratch;
char *t;
- if ((scratch = safe_strdup (str)) == NULL)
+ if ((scratch = str_dup (str)) == NULL)
return hints;
for (t = strtok (scratch, " ,.:\"()<>\n"); t;
t = strtok (NULL, " ,.:\"()<>\n")) {
- if (safe_strlen (t) > 3)
+ if (str_len (t) > 3)
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 (!keys)
return NULL;
- dprint (5, (debugfile, "crypt_getkeybyaddr: looking for %s <%s>.",
- a->personal, a->mailbox));
+ debug_print (5, ("looking for %s <%s>.\n", a->personal, a->mailbox));
for (k = keys; k; k = k->next) {
- dprint (5, (debugfile, " looking at key: %s `%.15s'\n",
- crypt_keyid (k), k->uid));
+ debug_print (5, (" looking at key: %s `%.15s'\n", crypt_keyid (k), k->uid));
if (abilities && !(k->flags & abilities)) {
- dprint (5, (debugfile, " insufficient abilities: Has %x, want %x\n",
- k->flags, abilities));
+ debug_print (5, (" insufficient abilities: Has %x, want %x\n", k->flags, abilities));
continue;
}
continue;
match = 0;
- dprint (5, (debugfile, "crypt_getkeybystr: matching \"%s\" against "
- "key %s, \"%s\": ", p, crypt_keyid (k), k->uid));
+ debug_print (5, ("matching \"%s\" against " "key %s, \"%s\":\n", p, crypt_keyid (k), k->uid));
- if (!*p || !safe_strcasecmp (p, crypt_keyid (k))
- || (!safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, crypt_keyid (k)))
+ if (!*p || !str_casecmp (p, crypt_keyid (k))
+ || (!str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, crypt_keyid (k)))
|| (option (OPTPGPLONGIDS)
- && !safe_strncasecmp (p, "0x", 2)
- && !safe_strcasecmp (p + 2, crypt_keyid (k) + 8))
+ && !str_ncasecmp (p, "0x", 2)
+ && !str_casecmp (p + 2, crypt_keyid (k) + 8))
|| str_isstr (k->uid, p)) {
crypt_key_t *tmp;
- dprint (5, (debugfile, "match.\n"));
+ debug_print (5, ("match.\n"));
*matches_endp = tmp = crypt_copy_key (k);
matches_endp = &tmp->next;
if (whatfor) {
for (l = id_defaults; l; l = l->next)
- if (!safe_strcasecmp (whatfor, l->what)) {
+ if (!str_casecmp (whatfor, l->what)) {
strfcpy (resp, NONULL (l->dflt), sizeof (resp));
break;
}
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 = safe_strdup (whatfor);
- l->dflt = safe_strdup (resp);
+ l->what = str_dup (whatfor);
+ l->dflt = str_dup (resp);
}
}
}
}
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;
*r_application &= ~APPLICATION_SMIME;
#endif
- keylist_size += safe_strlen (s) + 4 + 1;
- safe_realloc (&keylist, keylist_size);
+ keylist_size += str_len (s) + 4 + 1;
+ mem_realloc (&keylist, keylist_size);
sprintf (keylist + keylist_used, "%s0x%s%s", /* __SPRINTF_CHECKED__ */
keylist_used ? " " : "", s, forced_valid ? "!" : "");
}
- keylist_used = safe_strlen (keylist);
+ keylist_used = str_len (keylist);
crypt_free_key (&key);
rfc822_free_address (&addr);
if (is_smime)
choice =
mutt_multi_choice (_
- ("S/MIME (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
- _("esabtf"));
+ ("S/MIME (e)ncrypt, (s)ign, sign (a)s, (b)oth, (p)gp or (c)lear?"),
+ _("esabpfc"));
else
choice =
mutt_multi_choice (_
- ("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (t)oggle or (f)orget it?"),
- _("esabtf"));
+ ("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, s/(m)ime or (c)lear?"),
+ _("esabmfc"));
switch (choice) {
case 1: /* (e)ncrypt */
msg->security |= (is_smime ? SMIMEENCRYPT : PGPENCRYPT);
+ msg->security &= ~(is_smime ? SMIMESIGN : PGPSIGN);
break;
case 2: /* (s)ign */
msg->security |= (is_smime ? SMIMESIGN : PGPSIGN);
+ msg->security &= ~(is_smime ? SMIMEENCRYPT : PGPENCRYPT);
break;
case 3: /* sign (a)s */
msg->security |= (is_smime ? SMIMESIGN : PGPSIGN);
}
+#if 0
else {
msg->security &= (is_smime ? ~SMIMESIGN : ~PGPSIGN);
}
+#endif
*redraw = REDRAW_FULL;
break;
(is_smime ? (SMIMEENCRYPT | SMIMESIGN) : (PGPENCRYPT | PGPSIGN));
break;
- case 5: /* (t)oggle */
+ case 5: /* (p)gp or s/(m)ime */
is_smime = !is_smime;
break;
- case 6: /* (f)orget it */
+ case 6: /* (c)lear */
msg->security = 0;
break;
}
- if (choice == 6);
+ if (choice == 6 || choice == 7);
else if (is_smime) {
msg->security &= ~APPLICATION_PGP;
msg->security |= APPLICATION_SMIME;
int sender_length = 0;
int uid_length = 0;
- sender_length = safe_strlen (sender->mailbox);
+ sender_length = str_len (sender->mailbox);
for (uid = key->uids; uid && ret; uid = uid->next) {
- uid_length = safe_strlen (uid->email);
+ uid_length = str_len (uid->email);
if (1 && (uid->email[0] == '<')
&& (uid->email[uid_length - 1] == '>')
&& (uid_length == sender_length + 2)