]> granicus.if.org Git - neomutt/commitdiff
explicitly check retval for strcmp, buffer_len
authorRichard Russon <rich@flatcap.org>
Wed, 7 Aug 2019 21:02:04 +0000 (22:02 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 19 Aug 2019 23:14:28 +0000 (00:14 +0100)
autocrypt/autocrypt.c
email/parse.c

index bbe0a5f3327b96d55cb462e8f4b654d2e16339d8..834c5aa7ce31b2b89f8195d52448078ca6fa1ef1 100644 (file)
@@ -272,7 +272,7 @@ int mutt_autocrypt_process_autocrypt_header(struct Email *e, struct Envelope *en
 
   /* 1.1 spec also says to skip multipart/report emails */
   if ((e->content->type == TYPE_MULTIPART) &&
-      !(mutt_str_strcasecmp(e->content->subtype, "report")))
+      (mutt_str_strcasecmp(e->content->subtype, "report") == 0))
   {
     return 0;
   }
@@ -291,7 +291,7 @@ int mutt_autocrypt_process_autocrypt_header(struct Email *e, struct Envelope *en
     /* NOTE: this assumes the processing is occurring right after
      * mutt_parse_rfc822_line() and the from ADDR is still in the same
      * form (intl) as the autocrypt header addr field */
-    if (mutt_str_strcasecmp(from->mailbox, ac_hdr->addr))
+    if (mutt_str_strcasecmp(from->mailbox, ac_hdr->addr) != 0)
       continue;
 
     /* 1.1 spec says ignore all, if more than one valid header is found. */
@@ -325,7 +325,7 @@ int mutt_autocrypt_process_autocrypt_header(struct Email *e, struct Envelope *en
       update_db = 1;
       peer->autocrypt_timestamp = e->date_sent;
       peer->prefer_encrypt = valid_ac_hdr->prefer_encrypt;
-      if (mutt_str_strcmp(peer->keydata, valid_ac_hdr->keydata))
+      if (mutt_str_strcmp(peer->keydata, valid_ac_hdr->keydata) != 0)
       {
         import_gpg = 1;
         insert_db_history = 1;
@@ -455,7 +455,7 @@ int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_
      * addresses are normalized we use strcmp, not mutt_str_strcasecmp. */
     TAILQ_FOREACH(peer_addr, &recips, entries)
     {
-      if (!mutt_str_strcmp(peer_addr->mailbox, ac_hdr_addr.mailbox))
+      if (mutt_str_strcmp(peer_addr->mailbox, ac_hdr_addr.mailbox) == 0)
         break;
     }
 
@@ -478,8 +478,8 @@ int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_
       /* This is slightly different from the autocrypt 1.1 spec.
        * Avoid setting an empty peer.gossip_keydata with a value that matches
        * the current peer.keydata. */
-      if ((peer->gossip_keydata && mutt_str_strcmp(peer->gossip_keydata, ac_hdr->keydata)) ||
-          (!peer->gossip_keydata && mutt_str_strcmp(peer->keydata, ac_hdr->keydata)))
+      if ((peer->gossip_keydata && (mutt_str_strcmp(peer->gossip_keydata, ac_hdr->keydata) != 0)) ||
+          (!peer->gossip_keydata && (mutt_str_strcmp(peer->keydata, ac_hdr->keydata) != 0)))
       {
         import_gpg = 1;
         insert_db_history = 1;
@@ -634,7 +634,7 @@ enum AutocryptRec mutt_autocrypt_ui_recommendation(struct Email *e, char **keyli
       goto cleanup;
     }
 
-    if (mutt_buffer_len(keylist_buf))
+    if (mutt_buffer_len(keylist_buf) > 0)
       mutt_buffer_addch(keylist_buf, ' ');
     mutt_buffer_addstr(keylist_buf, matching_key);
 
@@ -908,7 +908,7 @@ void mutt_autocrypt_scan_mailboxes(void)
   {
     // L10N: The prompt for a mailbox to scan for Autocrypt: headers
     if ((!mutt_buffer_enter_fname(_("Scan mailbox"), folderbuf, 1)) &&
-        mutt_buffer_len(folderbuf))
+        (mutt_buffer_len(folderbuf) > 0))
     {
       mutt_buffer_expand_path_regex(folderbuf, false);
       struct Mailbox *m = mx_path_resolve(mutt_b2s(folderbuf));
index 462e9137c056d2f383d6266fdfa3b639b258c12b..1c92cd4386b69607d785e7ecb6143a961ecb801f 100644 (file)
@@ -569,7 +569,7 @@ static struct AutocryptHeader *parse_autocrypt(struct AutocryptHeader *head, con
   struct Parameter *p = NULL;
   TAILQ_FOREACH(p, &pl, entries)
   {
-    if (!mutt_str_strcasecmp(p->attribute, "addr"))
+    if (mutt_str_strcasecmp(p->attribute, "addr") == 0)
     {
       if (autocrypt->addr)
       {
@@ -579,12 +579,12 @@ static struct AutocryptHeader *parse_autocrypt(struct AutocryptHeader *head, con
       autocrypt->addr = p->value;
       p->value = NULL;
     }
-    else if (!mutt_str_strcasecmp(p->attribute, "prefer-encrypt"))
+    else if (mutt_str_strcasecmp(p->attribute, "prefer-encrypt") == 0)
     {
-      if (!mutt_str_strcasecmp(p->value, "mutual"))
+      if (mutt_str_strcasecmp(p->value, "mutual") == 0)
         autocrypt->prefer_encrypt = 1;
     }
-    else if (!mutt_str_strcasecmp(p->attribute, "keydata"))
+    else if (mutt_str_strcasecmp(p->attribute, "keydata") == 0)
     {
       if (autocrypt->keydata)
       {