From 3c83c11d7e8d3a2ec0f52fe40818a7faaa3ef52f Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 24 Jul 2019 18:59:07 -0700 Subject: [PATCH] Fix process_gossip_headers() to look at the right envelope Co-authored-by: Richard Russon --- autocrypt/autocrypt.c | 9 ++++++--- autocrypt/autocrypt.h | 2 +- commands.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/autocrypt/autocrypt.c b/autocrypt/autocrypt.c index 9aab282bb..500bb706a 100644 --- a/autocrypt/autocrypt.c +++ b/autocrypt/autocrypt.c @@ -311,8 +311,9 @@ cleanup: return rv; } -int mutt_autocrypt_process_gossip_header(struct Email *hdr, struct Envelope *env) +int mutt_autocrypt_process_gossip_header(struct Email *hdr, struct Envelope *prot_headers) { + struct Envelope *env; struct AutocryptHeader *ac_hdr; struct timeval now; struct AutocryptPeer *peer = NULL; @@ -329,9 +330,11 @@ int mutt_autocrypt_process_gossip_header(struct Email *hdr, struct Envelope *env if (mutt_autocrypt_init(0)) return -1; - if (!hdr || !hdr->content || !env) + if (!hdr || !hdr->env || !prot_headers) return 0; + env = hdr->env; + struct Address *from = TAILQ_FIRST(&env->from); if (!from) return 0; @@ -352,7 +355,7 @@ int mutt_autocrypt_process_gossip_header(struct Email *hdr, struct Envelope *env mutt_addrlist_copy(&recips, &env->reply_to, false); mutt_autocrypt_db_normalize_addrlist(&recips); - for (ac_hdr = env->autocrypt_gossip; ac_hdr; ac_hdr = ac_hdr->next) + for (ac_hdr = prot_headers->autocrypt_gossip; ac_hdr; ac_hdr = ac_hdr->next) { if (ac_hdr->invalid) continue; diff --git a/autocrypt/autocrypt.h b/autocrypt/autocrypt.h index 95a77305a..6ca8a347a 100644 --- a/autocrypt/autocrypt.h +++ b/autocrypt/autocrypt.h @@ -79,7 +79,7 @@ enum AutocryptRec int mutt_autocrypt_init (int); void mutt_autocrypt_cleanup (void); int mutt_autocrypt_process_autocrypt_header (struct Email *hdr, struct Envelope *env); -int mutt_autocrypt_process_gossip_header (struct Email *hdr, struct Envelope *env); +int mutt_autocrypt_process_gossip_header (struct Email *hdr, struct Envelope *prot_headers); enum AutocryptRec mutt_autocrypt_ui_recommendation (struct Email *hdr, char **keylist); int mutt_autocrypt_set_sign_as_default_key (struct Email *hdr); int mutt_autocrypt_write_autocrypt_header (struct Envelope *env, FILE *fp); diff --git a/commands.c b/commands.c index 2d369c866..69db23fb1 100644 --- a/commands.c +++ b/commands.c @@ -181,7 +181,7 @@ static void process_protected_headers(struct Email *e) #ifdef USE_AUTOCRYPT if (C_Autocrypt && (e->security & SEC_ENCRYPT) && prot_headers && prot_headers->autocrypt_gossip) { - mutt_autocrypt_process_gossip_header(e, e->env); + mutt_autocrypt_process_gossip_header(e, prot_headers); } #endif } -- 2.50.1