]> granicus.if.org Git - neomutt/commitdiff
Fix latest coverity issues (#624)
authorPietro Cerutti <gahr@gahr.ch>
Thu, 8 Jun 2017 13:51:16 +0000 (14:51 +0100)
committerGitHub <noreply@github.com>
Thu, 8 Jun 2017 13:51:16 +0000 (14:51 +0100)
* Fix latest coverity issues

ncrypt/crypt.c
CID 170494:  Resource leaks  (RESOURCE_LEAK)
Variable "from" going out of scope leaks the storage it points to.

nntp.c
CID 170495:  Uninitialized variables  (UNINIT)
Declaring variable "buf" without initializer.

parse.c
CID 76957:  Error handling issues  (NEGATIVE_RETURNS)
"loc" is passed to a parameter that cannot be negative.

ncrypt/crypt.c
nntp.c
parse.c

index 6da4821415f3f45d969f3bc4283b082c5eeecc90..f62c99453039529724d59f993063229608f85069 100644 (file)
@@ -182,7 +182,7 @@ int mutt_protect(struct Header *msg, char *keylist)
   {
     /* Set sender (necessary for e.g. PKA).  */
     const char *mailbox = NULL;
-    const struct Address *from = msg->env->from;
+    struct Address *from = msg->env->from;
 
     if (!from)
       from = mutt_default_from();
@@ -195,6 +195,9 @@ int mutt_protect(struct Header *msg, char *keylist)
       crypt_smime_set_sender(mailbox);
     else if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
       crypt_pgp_set_sender(mailbox);
+
+    if (!msg->env->from)
+      rfc822_free_address(&from);
   }
 
   if (msg->security & SIGN)
diff --git a/nntp.c b/nntp.c
index 8c758a9589a42731b297555706ca3cc6f1fdfa7d..4e7605aeb7d529dbf0915f970af59bc7d3a7bd61 100644 (file)
--- a/nntp.c
+++ b/nntp.c
@@ -740,7 +740,7 @@ int nntp_open_connection(struct NntpServer *nserv)
 static int nntp_query(struct NntpData *nntp_data, char *line, size_t linelen)
 {
   struct NntpServer *nserv = nntp_data->nserv;
-  char buf[LONG_STRING];
+  char buf[LONG_STRING] = {0};
 
   if (nserv->status == NNTP_BYE)
     return -1;
diff --git a/parse.c b/parse.c
index 52aac10c49dfc4d05df9ab617c48e0616fb057a2..eaaec121b8597560ceb67343368b318ae1892ac1 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1412,8 +1412,11 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr,
     }
   }
 
-  while ((loc = ftello(f)), *(line = mutt_read_rfc822_line(f, line, &linelen)) != 0)
+  while ((loc = ftello(f)) != -1)
   {
+    line = mutt_read_rfc822_line(f, line, &linelen);
+    if (*line == '\0')
+      break;
     if ((p = strpbrk(line, ": \t")) == NULL || *p != ':')
     {
       char return_path[LONG_STRING];