From bf9ce16b2ef9d36b3a3968b9c55ef469437167c6 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Thu, 22 Mar 2018 20:04:46 -0700 Subject: [PATCH] Fix comparison of flags with multiple bits set. PGPENCRYPT, PGPKEY, SMIMEENCRYPT, and SMIMEOPAQUE are all combination flags, with multiple bits set. In a few places these flags were bitwise-and'ed incorrectly: expecting a non-zero result to indicate all the bits in the flag were set. Change those to explicitly compare the result against the original flag. --- hdrline.c | 2 +- pattern.c | 2 +- recvattach.c | 2 +- sendlib.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hdrline.c b/hdrline.c index fd0bb77da..4e77975d7 100644 --- a/hdrline.c +++ b/hdrline.c @@ -1250,7 +1250,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co ch = "P"; else if ((WithCrypto != 0) && (hdr->security & SIGN)) ch = "s"; - else if (((WithCrypto & APPLICATION_PGP) != 0) && (hdr->security & PGPKEY)) + else if (((WithCrypto & APPLICATION_PGP) != 0) && ((hdr->security & PGPKEY) == PGPKEY)) ch = "K"; else ch = " "; diff --git a/pattern.c b/pattern.c index 28b1f82eb..6a49d03f3 100644 --- a/pattern.c +++ b/pattern.c @@ -1710,7 +1710,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, case MUTT_PGP_KEY: if (!(WithCrypto & APPLICATION_PGP)) break; - return (pat->not ^ ((h->security & APPLICATION_PGP) && (h->security & PGPKEY))); + return (pat->not ^ ((h->security & PGPKEY) == PGPKEY)); case MUTT_XLABEL: if (!h->env) return 0; diff --git a/recvattach.c b/recvattach.c index 38b48f1dd..404033375 100644 --- a/recvattach.c +++ b/recvattach.c @@ -997,7 +997,7 @@ static void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Header secured = !crypt_smime_decrypt_mime(fp, &new_fp, m, &new_body); /* S/MIME nesting */ - if ((mutt_is_application_smime(new_body) & SMIMEOPAQUE)) + if ((mutt_is_application_smime(new_body) & SMIMEOPAQUE) == SMIMEOPAQUE) { struct Body *outer_new_body = new_body; FILE *outer_fp = new_fp; diff --git a/sendlib.c b/sendlib.c index 6c7ed46c4..abb6982ba 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1395,14 +1395,14 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, i pgp &= ~PGPENCRYPT; } else if (((WithCrypto & APPLICATION_PGP) != 0) && - (mutt_is_application_pgp(hdr->content) & PGPENCRYPT)) + ((mutt_is_application_pgp(hdr->content) & PGPENCRYPT) == PGPENCRYPT)) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV; pgp &= ~PGPENCRYPT; } else if (((WithCrypto & APPLICATION_SMIME) != 0) && - mutt_is_application_smime(hdr->content) & SMIMEENCRYPT) + ((mutt_is_application_smime(hdr->content) & SMIMEENCRYPT) == SMIMEENCRYPT)) { chflags |= CH_MIME | CH_TXTPLAIN; cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV; -- 2.40.0