]> granicus.if.org Git - neomutt/commitdiff
Fix comparison of flags with multiple bits set.
authorKevin McCarthy <kevin@8t8.us>
Fri, 23 Mar 2018 03:04:46 +0000 (20:04 -0700)
committerRichard Russon <rich@flatcap.org>
Sun, 25 Mar 2018 22:57:25 +0000 (23:57 +0100)
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
pattern.c
recvattach.c
sendlib.c

index fd0bb77daa89adec51825e7978b7603cbd9c2296..4e77975d7e013384f1ba813c2cf1d5a637a74574 100644 (file)
--- 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 = " ";
index 28b1f82ebeb4408fc7d3d2a71255759f659c1f2c..6a49d03f3ad0e6ff640ad0a0ed59a83a7f665a7b 100644 (file)
--- 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;
index 38b48f1dd77d5a766ee8e30e947c94d664d71833..404033375d4e543c405523c4c9f19c583cef11c8 100644 (file)
@@ -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;
index 6c7ed46c4132bb989466c6d51ef06c9041ee8dd9..abb6982ba8034a6a345f533ccf48882257b4c865 100644 (file)
--- 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;