]> granicus.if.org Git - mutt/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)
committerKevin McCarthy <kevin@8t8.us>
Fri, 23 Mar 2018 03:04:46 +0000 (20:04 -0700)
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 ba118bf572169f94e71bb3a8ad42a8f89bea15d9..ea76e83653d1f0cf387ebb0a6eefb48c009fbe59 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -688,7 +688,8 @@ hdr_format_str (char *dest,
        ch = 'P';
       else if (WithCrypto && hdr->security & SIGN)
         ch = 's';
-      else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY)
+      else if ((WithCrypto & APPLICATION_PGP) &&
+               ((hdr->security & PGPKEY) == PGPKEY))
         ch = 'K';
 
       snprintf (buf2, sizeof (buf2),
index d71252f2e239c6beb8857d956f87df00b9903d22..285cbfa6f384cfa2caef1e4690fe06f28f13ed72 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1323,7 +1323,7 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx,
    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:
       return (pat->not ^ (h->env->x_label && patmatch (pat, h->env->x_label) == 0));
     case MUTT_HORMEL:
index 07c4ba8c29a7799c7aca80aad1d47b8b79af736d..768e1d6f6db25dbc2ba8bc1f9b3fddb111bd6bfa 100644 (file)
@@ -955,7 +955,7 @@ static void mutt_generate_recvattach_list (ATTACH_CONTEXT *actx,
       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)
       {
         BODY *outer_new_body = new_body;
         FILE *outer_fp = new_fp;
index da1e505388480e095633387cc3d85cb7dbcc011d..ef428541ba9ecf402a2d09bffa312d21862e0600 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1321,15 +1321,15 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
       cmflags = MUTT_CM_DECODE_PGP;
       pgp &= ~PGPENCRYPT;
     }
-    else if ((WithCrypto & APPLICATION_PGP)
-             && (mutt_is_application_pgp (hdr->content) & PGPENCRYPT))
+    else if ((WithCrypto & APPLICATION_PGP) &&
+             ((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)
-              && mutt_is_application_smime (hdr->content) & SMIMEENCRYPT)
+    else if ((WithCrypto & APPLICATION_SMIME) &&
+             ((mutt_is_application_smime (hdr->content) & SMIMEENCRYPT) == SMIMEENCRYPT))
     {
       chflags |= CH_MIME | CH_TXTPLAIN;
       cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV;