X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=crypt-gpgme.c;h=ed847138eb811eba0f038138bc217beb4e67a6bd;hp=03eb846583a87b33cd8155d5a40c23020bb8a912;hb=cf69ddd650f124d3aed242285434ba2b97fb4b79;hpb=5251a17c26fadd6559295f6962f831a97eeeefdb diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 03eb846..ed84713 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -128,12 +128,12 @@ static void print_utf8 (FILE * fp, const char *buf, size_t len) { 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); } @@ -149,7 +149,7 @@ static const char *crypt_keyid (crypt_key_t * k) if (k->kobj && k->kobj->subkeys) { s = k->kobj->subkeys->keyid; - if ((!option (OPTPGPLONGIDS)) && (mutt_strlen (s) == 16)) + if ((!option (OPTPGPLONGIDS)) && (str_len (s) == 16)) /* Return only the short keyID. */ s += 8; } @@ -212,7 +212,7 @@ static crypt_key_t *crypt_copy_key (crypt_key_t * key) { 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; @@ -229,7 +229,7 @@ static void crypt_free_key (crypt_key_t ** keylist) while (*keylist) { crypt_key_t *k = (*keylist)->next; - FREE (&k); + mem_free (&k); *keylist = k; } } @@ -295,11 +295,11 @@ static int crypt_id_matches_addr (ADDRESS * addr, ADDRESS * u_addr, 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; @@ -505,7 +505,7 @@ static char *data_object_to_tempfile (gpgme_data_t data, FILE ** ret_fp) } if (ret_fp) *ret_fp = fp; - return safe_strdup (tempfile); + return str_dup (tempfile); } @@ -550,13 +550,13 @@ static gpgme_key_t *create_recipient_set (const char *keylist, 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; } } @@ -564,7 +564,7 @@ static gpgme_key_t *create_recipient_set (const char *keylist, } /* NULL terminate. */ - safe_realloc (&rset, sizeof (*rset) * (rset_n + 1)); + mem_realloc (&rset, sizeof (*rset) * (rset_n + 1)); rset[rset_n++] = NULL; if (context) @@ -757,7 +757,7 @@ static BODY *sign_message (BODY * a, int use_smime) 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; @@ -781,15 +781,15 @@ static BODY *sign_message (BODY * a, int use_smime) 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; @@ -832,19 +832,19 @@ BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign) 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; @@ -854,18 +854,18 @@ BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign) 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; @@ -890,25 +890,25 @@ BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist) 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; @@ -1003,7 +1003,7 @@ static int show_sig_summary (unsigned long sum, state_attach_puts (": ", s); if (t0) state_attach_puts (t0, s); - if (t1 && !(t0 && !mutt_strcmp (t0, t1))) { + if (t1 && !(t0 && !str_cmp (t0, t1))) { if (t0) state_attach_puts (",", s); state_attach_puts (t1, s); @@ -1030,10 +1030,10 @@ static void show_fingerprint (gpgme_key_t key, STATE * state) return; is_pgp = (key->protocol == GPGME_PROTOCOL_OpenPGP); - buf = safe_malloc (mutt_strlen (prefix) + mutt_strlen (s) * 4 + 2); + buf = mem_malloc (str_len (prefix) + str_len (s) * 4 + 2); strcpy (buf, prefix); /* __STRCPY_CHECKED__ */ - p = buf + mutt_strlen (buf); - if (is_pgp && mutt_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]; @@ -1060,7 +1060,7 @@ static void show_fingerprint (gpgme_key_t key, STATE * state) *p++ = '\n'; *p = 0; state_attach_puts (buf, state); - FREE (&buf); + mem_free (&buf); } /* Show the valididy of a key used for one signature. */ @@ -1298,7 +1298,7 @@ static int verify_one (BODY * sigbdy, STATE * s, if (notation->value) { state_attach_puts (notation->value, s); if (!(*notation->value - && (notation->value[mutt_strlen (notation->value) - 1] == + && (notation->value[str_len (notation->value) - 1] == '\n'))) state_attach_puts ("\n", s); } @@ -1656,10 +1656,10 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, } while (fgets (buf, sizeof (buf), tfp)) { - if (!safe_strncmp ("-----BEGIN PGP ", buf, 15)) { - if (!mutt_strcmp ("MESSAGE-----\n", buf + 15)) + if (!str_ncmp ("-----BEGIN PGP ", buf, 15)) { + if (!str_cmp ("MESSAGE-----\n", buf + 15)) enc = 1; - else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15)) + else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15)) sgn = 1; } } @@ -1725,7 +1725,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset) if (!fname) return; unlink (fname); - FREE (&fname); + mem_free (&fname); fc = fgetconv_open (fp, charset, Charset, M_ICONV_HOOK_FROM); @@ -1738,7 +1738,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset) continue; } - if (!mutt_strcmp (buf, "-----BEGIN PGP SIGNATURE-----\n")) + if (!str_cmp (buf, "-----BEGIN PGP SIGNATURE-----\n")) break; if (armor_header) { @@ -1795,21 +1795,21 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) break; offset = ftell (s->fpin); - bytes -= (offset - last_pos); /* don't rely on mutt_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 (!mutt_strcmp ("MESSAGE-----\n", buf + 15)) + if (!str_cmp ("MESSAGE-----\n", buf + 15)) needpass = 1; - else if (!mutt_strcmp ("SIGNED MESSAGE-----\n", buf + 15)) { + else if (!str_cmp ("SIGNED MESSAGE-----\n", buf + 15)) { clearsign = 1; needpass = 0; } else if (!option (OPTDONTHANDLEPGPKEYS) && - !mutt_strcmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) { + !str_cmp ("PUBLIC KEY BLOCK-----\n", buf + 15)) { needpass = 0; pgp_keyblock = 1; } @@ -1825,18 +1825,18 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) /* Copy PGP material to an data container */ armored_data = create_gpgme_data (); - gpgme_data_write (armored_data, buf, mutt_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 mutt_strlen(buf) */ + bytes -= (offset - last_pos); /* don't rely on str_len(buf) */ last_pos = offset; - gpgme_data_write (armored_data, buf, mutt_strlen (buf)); + gpgme_data_write (armored_data, buf, str_len (buf)); - if ((needpass && !mutt_strcmp ("-----END PGP MESSAGE-----\n", buf)) + if ((needpass && !str_cmp ("-----END PGP MESSAGE-----\n", buf)) || (!needpass - && (!mutt_strcmp ("-----END PGP SIGNATURE-----\n", buf) - || !mutt_strcmp ("-----END PGP PUBLIC KEY BLOCK-----\n", + && (!str_cmp ("-----END PGP SIGNATURE-----\n", buf) + || !str_cmp ("-----END PGP PUBLIC KEY BLOCK-----\n", buf)))) break; } @@ -1917,7 +1917,7 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) } else { unlink (tmpfname); - FREE (&tmpfname); + mem_free (&tmpfname); } } gpgme_release (ctx); @@ -2368,10 +2368,10 @@ 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 ((*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) @@ -2388,10 +2388,10 @@ static int _crypt_compare_keyid (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) @@ -2417,7 +2417,7 @@ static int _crypt_compare_date (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) @@ -2462,9 +2462,9 @@ static int _crypt_compare_trust (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) @@ -2480,10 +2480,10 @@ static int print_dn_part (FILE * fp, struct dn_array_s *dn, const char *key) int any = 0; for (; dn->key; dn++) { - if (!mutt_strcmp (dn->key, key)) { + if (!str_cmp (dn->key, key)) { if (any) fputs (" + ", fp); - print_utf8 (fp, dn->value, mutt_strlen (dn->value)); + print_utf8 (fp, dn->value, str_len (dn->value)); any = 1; } } @@ -2506,7 +2506,7 @@ static void print_dn_parts (FILE * fp, struct dn_array_s *dn) /* now print the rest without any specific ordering */ for (; dn->key; dn++) { for (i = 0; stdpart[i]; i++) { - if (!mutt_strcmp (dn->key, stdpart[i])) + if (!str_cmp (dn->key, stdpart[i])) break; } if (!stdpart[i]) { @@ -2538,7 +2538,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, 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; @@ -2552,7 +2552,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, 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); @@ -2582,7 +2582,7 @@ static const unsigned char *parse_dn_part (struct dn_array_s *array, n++; } - p = safe_malloc (n + 1); + p = mem_malloc (n + 1); array->value = (char *) p; for (s = string; n; s++, n--) { if (*s == '\\') { @@ -2613,7 +2613,7 @@ static struct dn_array_s *parse_dn (const unsigned char *string) 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 == ' ') @@ -2624,12 +2624,12 @@ static struct dn_array_s *parse_dn (const unsigned char *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; @@ -2651,10 +2651,10 @@ static struct dn_array_s *parse_dn (const unsigned char *string) 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; } @@ -2685,10 +2685,10 @@ static void parse_and_print_user_id (FILE * fp, const char *userid) 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); } } } @@ -2759,7 +2759,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) putc (' ', fp); } if (is_pgp) - print_utf8 (fp, s, mutt_strlen (s)); + print_utf8 (fp, s, str_len (s)); else parse_and_print_user_id (fp, s); putc ('\n', fp); @@ -2821,7 +2821,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) if (key->subkeys) { s = key->subkeys->fpr; fputs (_("Fingerprint: "), fp); - if (is_pgp && mutt_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); @@ -2867,7 +2867,7 @@ static void print_key_info (gpgme_key_t key, FILE * fp) s = subkey->keyid; putc ('\n', fp); - if (mutt_strlen (s) == 16) + if (str_len (s) == 16) s += 8; /* display only the short keyID */ fprintf (fp, "Subkey ....: 0x%s", s); if (subkey->revoked) { @@ -2980,7 +2980,7 @@ static void verify_key (crypt_key_t * key) k = key->kobj; gpgme_key_ref (k); - while ((s = k->chain_id) && k->subkeys && mutt_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); @@ -3035,7 +3035,7 @@ static char *list_to_pattern (LIST * list) 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) { @@ -3083,7 +3083,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, err = gpgme_new (&ctx); if (err) { mutt_error (_("gpgme_new failed: %s"), gpgme_strerror (err)); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3106,20 +3106,20 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, 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)); gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3152,7 +3152,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, #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; @@ -3175,7 +3175,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, if (err) { mutt_error (_("gpgme_op_keylist_start failed: %s"), gpgme_strerror (err)); gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return NULL; } @@ -3188,7 +3188,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, 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; @@ -3203,7 +3203,7 @@ static crypt_key_t *get_candidates (LIST * hints, unsigned int app, } gpgme_release (ctx); - FREE (&pattern); + mem_free (&pattern); return db; } @@ -3214,16 +3214,16 @@ static LIST *crypt_add_string_to_hints (LIST * hints, const char *str) 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 (mutt_strlen (t) > 3) + if (str_len (t) > 3) hints = mutt_add_list (hints, t); } - FREE (&scratch); + mem_free (&scratch); return hints; } @@ -3257,7 +3257,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t * keys, 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; @@ -3415,7 +3415,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t * keys, } mutt_menuDestroy (&menu); - FREE (&key_table); + mem_free (&key_table); set_option (OPTNEEDREDRAW); @@ -3568,12 +3568,12 @@ static crypt_key_t *crypt_getkeybystr (char *p, short abilities, match = 0; 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; @@ -3620,7 +3620,7 @@ static crypt_key_t *crypt_ask_for_key (char *tag, 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; } @@ -3636,11 +3636,11 @@ static crypt_key_t *crypt_ask_for_key (char *tag, 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); } } @@ -3727,7 +3727,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, } } else if (r == -1) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -3746,7 +3746,7 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, app, #endif &forced_valid)) == NULL) { - FREE (&keylist); + mem_free (&keylist); rfc822_free_address (&tmp); rfc822_free_address (&addr); return NULL; @@ -3765,12 +3765,12 @@ static char *find_keys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc, *r_application &= ~APPLICATION_SMIME; #endif - keylist_size += mutt_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 = mutt_strlen (keylist); + keylist_used = str_len (keylist); crypt_free_key (&key); rfc822_free_address (&addr); @@ -3827,21 +3827,23 @@ static int gpgme_send_menu (HEADER * msg, int *redraw, int is_smime) 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 */ @@ -3856,9 +3858,11 @@ static int gpgme_send_menu (HEADER * msg, int *redraw, int is_smime) msg->security |= (is_smime ? SMIMESIGN : PGPSIGN); } +#if 0 else { msg->security &= (is_smime ? ~SMIMESIGN : ~PGPSIGN); } +#endif *redraw = REDRAW_FULL; break; @@ -3867,16 +3871,16 @@ static int gpgme_send_menu (HEADER * msg, int *redraw, int is_smime) (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; @@ -3920,9 +3924,9 @@ static int verify_sender (HEADER * h, gpgme_protocol_t protocol) int sender_length = 0; int uid_length = 0; - sender_length = mutt_strlen (sender->mailbox); + sender_length = str_len (sender->mailbox); for (uid = key->uids; uid && ret; uid = uid->next) { - uid_length = mutt_strlen (uid->email); + uid_length = str_len (uid->email); if (1 && (uid->email[0] == '<') && (uid->email[uid_length - 1] == '>') && (uid_length == sender_length + 2)