From: Kevin McCarthy Date: Sun, 20 Oct 2019 06:06:24 +0000 (+0800) Subject: Remove make_key_attachment parameter. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15f89f8e6b4a2388065c09665813e95c9464db3e;p=mutt Remove make_key_attachment parameter. The parameter is not actually used anywhere. The next commit will convert the classic pgp implementation to use the buffer pool. This change will simplify the logic. --- diff --git a/compose.c b/compose.c index 484435f4..c0a3f6d0 100644 --- a/compose.c +++ b/compose.c @@ -1053,7 +1053,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ break; new = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); - if ((new->content = crypt_pgp_make_key_attachment(NULL)) != NULL) + if ((new->content = crypt_pgp_make_key_attachment()) != NULL) { update_idx (menu, actx, new); menu->redraw |= REDRAW_INDEX; diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 697da3f5..35441d2c 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -5157,7 +5157,7 @@ cleanup: return rv; } -BODY *pgp_gpgme_make_key_attachment (char *tempf) +BODY *pgp_gpgme_make_key_attachment (void) { crypt_key_t *key = NULL; gpgme_ctx_t context = NULL; @@ -5166,6 +5166,7 @@ BODY *pgp_gpgme_make_key_attachment (char *tempf) gpgme_error_t err; BODY *att = NULL; char buff[LONG_STRING]; + char *attfilename; struct stat sb; unset_option (OPTPGPCHECKTRUST); @@ -5188,13 +5189,13 @@ BODY *pgp_gpgme_make_key_attachment (char *tempf) goto bail; } - tempf = data_object_to_tempfile (keydata, tempf, NULL); - if (!tempf) + attfilename = data_object_to_tempfile (keydata, NULL, NULL); + if (!attfilename) goto bail; att = mutt_new_body (); - /* tempf is a newly allocated string, so this is correct: */ - att->filename = tempf; + /* attfilename is a newly allocated string, so this is correct: */ + att->filename = attfilename; att->unlink = 1; att->use_disp = 0; att->type = TYPEAPPLICATION; @@ -5207,7 +5208,7 @@ BODY *pgp_gpgme_make_key_attachment (char *tempf) att->description = safe_strdup (buff); mutt_update_encoding (att); - stat (tempf, &sb); + stat (attfilename, &sb); att->length = sb.st_size; bail: diff --git a/crypt-gpgme.h b/crypt-gpgme.h index 827d86a8..207bcc4f 100644 --- a/crypt-gpgme.h +++ b/crypt-gpgme.h @@ -40,7 +40,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s); int smime_gpgme_application_handler (BODY *a, STATE *s); int pgp_gpgme_encrypted_handler (BODY *a, STATE *s); -BODY *pgp_gpgme_make_key_attachment (char *tempf); +BODY *pgp_gpgme_make_key_attachment (void); BODY *pgp_gpgme_sign_message (BODY *a); BODY *smime_gpgme_sign_message (BODY *a); diff --git a/crypt-mod-pgp-classic.c b/crypt-mod-pgp-classic.c index 8aaaef85..2773a818 100644 --- a/crypt-mod-pgp-classic.c +++ b/crypt-mod-pgp-classic.c @@ -71,9 +71,9 @@ static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign) return pgp_encrypt_message (a, keylist, sign); } -static BODY *crypt_mod_pgp_make_key_attachment (char *tempf) +static BODY *crypt_mod_pgp_make_key_attachment (void) { - return pgp_make_key_attachment (tempf); + return pgp_make_key_attachment (); } static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int just_one) diff --git a/crypt-mod-pgp-gpgme.c b/crypt-mod-pgp-gpgme.c index b10a6e0e..b2eb6377 100644 --- a/crypt-mod-pgp-gpgme.c +++ b/crypt-mod-pgp-gpgme.c @@ -95,9 +95,9 @@ static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign) return pgp_gpgme_encrypt_message (a, keylist, sign); } -static BODY *crypt_mod_pgp_make_key_attachment (char *tempf) +static BODY *crypt_mod_pgp_make_key_attachment (void) { - return pgp_gpgme_make_key_attachment (tempf); + return pgp_gpgme_make_key_attachment (); } static void crypt_mod_pgp_set_sender (const char *sender) diff --git a/crypt-mod.h b/crypt-mod.h index 1a03e1fc..afce2335 100644 --- a/crypt-mod.h +++ b/crypt-mod.h @@ -42,7 +42,7 @@ typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b, int just_one); typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags, char *keylist); -typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf); +typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (void); typedef char *(*crypt_func_findkeys_t) (ADDRESS *adrlist, int oppenc_mode); typedef BODY *(*crypt_func_sign_message_t) (BODY *a); typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist, diff --git a/cryptglue.c b/cryptglue.c index d0e03167..2cf3942b 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -243,10 +243,10 @@ BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist) } /* Generate a PGP public key attachment. */ -BODY *crypt_pgp_make_key_attachment (char *tempf) +BODY *crypt_pgp_make_key_attachment (void) { if (CRYPT_MOD_CALL_CHECK (PGP, pgp_make_key_attachment)) - return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (tempf); + return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (); return NULL; } diff --git a/mutt_crypt.h b/mutt_crypt.h index 4f20e7da..ea0337a5 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -231,7 +231,7 @@ BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist); void crypt_pgp_free_key (pgp_key_t *kpp); /* Generate a PGP public key attachment. */ -BODY *crypt_pgp_make_key_attachment (char *tempf); +BODY *crypt_pgp_make_key_attachment (void); /* This routine attempts to find the keyids of the recipients of a message. It returns NULL if any of the keys can not be found. diff --git a/pgp.h b/pgp.h index 223e5c20..a62e251a 100644 --- a/pgp.h +++ b/pgp.h @@ -30,7 +30,7 @@ int pgp_use_gpg_agent(void); int pgp_check_traditional (FILE *, BODY *, int); BODY *pgp_decrypt_part (BODY *, STATE *, FILE *, BODY *); -BODY *pgp_make_key_attachment (char *); +BODY *pgp_make_key_attachment (void); const char *pgp_micalg (const char *fname); char *_pgp_keyid (pgp_key_t); diff --git a/pgpkey.c b/pgpkey.c index 129b4247..67626111 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -716,7 +716,7 @@ pgp_key_t pgp_ask_for_key (char *tag, char *whatfor, /* generate a public key attachment */ -BODY *pgp_make_key_attachment (char *tempf) +BODY *pgp_make_key_attachment (void) { BODY *att; char buff[LONG_STRING]; @@ -727,6 +727,7 @@ BODY *pgp_make_key_attachment (char *tempf) pid_t thepid; pgp_key_t key; unset_option (OPTPGPCHECKTRUST); + const char *tempf = NULL; key = pgp_ask_for_key (_("Please enter the key ID: "), NULL, 0, PGP_PUBRING); diff --git a/send.c b/send.c index 7299a4e6..85b39cf6 100644 --- a/send.c +++ b/send.c @@ -966,7 +966,7 @@ generate_body (FILE *tempfp, /* stream for outgoing message */ BODY *tmp; if ((WithCrypto & APPLICATION_PGP) - && (tmp = crypt_pgp_make_key_attachment (NULL)) == NULL) + && (tmp = crypt_pgp_make_key_attachment ()) == NULL) return -1; tmp->next = msg->content;