]> granicus.if.org Git - neomutt/commitdiff
carefully check all regex pointers
authorRichard Russon <rich@flatcap.org>
Fri, 9 Feb 2018 03:41:26 +0000 (03:41 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 9 Feb 2018 03:52:56 +0000 (03:52 +0000)
browser.c
imap/browse.c
init.c
mutt/regex.c
muttlib.c
ncrypt/pgp.c
pager.c
parse.c
send.c

index 4d2a3b5942a5d592b1466846854c27efd6412b9a..a05a81adbfe4e64a6e05cc463b3a23f0fc48c23e 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -730,7 +730,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
         continue;
       if (prefix && *prefix && (strncmp(prefix, nntp_data->group, strlen(prefix)) != 0))
         continue;
-      if (Mask && !((regexec(Mask->regex, nntp_data->group, 0, NULL, 0) == 0) ^ Mask->not))
+      if (Mask && Mask->regex && !((regexec(Mask->regex, nntp_data->group, 0, NULL, 0) == 0) ^ Mask->not))
         continue;
       add_folder(menu, state, nntp_data->group, NULL, NULL, NULL, nntp_data);
     }
@@ -788,7 +788,7 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
       {
         continue;
       }
-      if (Mask && !((regexec(Mask->regex, de->d_name, 0, NULL, 0) == 0) ^ Mask->not))
+      if (Mask && Mask->regex && !((regexec(Mask->regex, de->d_name, 0, NULL, 0) == 0) ^ Mask->not))
         continue;
 
       mutt_file_concat_path(buffer, d, de->d_name, sizeof(buffer));
@@ -1814,7 +1814,7 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi
           }
           else
           {
-            if (Mask)
+            if (Mask && Mask->regex)
             {
               regfree(Mask->regex);
               FREE(&Mask->regex);
index d82eacc3a6c3fbca7dab15ddfcf5042148c3972a..fafa56858eab0e4f1131c5d2e270606053b2783e 100644 (file)
@@ -92,7 +92,7 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors,
   /* apply filemask filter. This should really be done at menu setup rather
    * than at scan, since it's so expensive to scan. But that's big changes
    * to browser.c */
-  if (Mask && !((regexec(Mask->regex, relpath, 0, NULL, 0) == 0) ^ Mask->not))
+  if (Mask && Mask->regex && !((regexec(Mask->regex, relpath, 0, NULL, 0) == 0) ^ Mask->not))
   {
     FREE(&mx.mbox);
     return;
diff --git a/init.c b/init.c
index ca11b8ba41ac6943f88885906bfda8de62d22fae..7010daac0cdc8f614a06c3dcacb919244667871c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -378,7 +378,7 @@ int mutt_option_set(const struct Option *val, struct Buffer *err)
               if (e && e->subject)
               {
                 e->real_subj = e->subject;
-                if (ReplyRegex &&
+                if (ReplyRegex && ReplyRegex->regex &&
                     (regexec(ReplyRegex->regex, e->subject, 1, pmatch, 0) == 0))
                 {
                   e->subject += pmatch[0].rm_eo;
@@ -2604,7 +2604,7 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
             struct Envelope *e = Context->hdrs[i]->env;
             if (e && e->subject)
             {
-              e->real_subj = (ReplyRegex &&
+              e->real_subj = (ReplyRegex && ReplyRegex->regex &&
                               (regexec(ReplyRegex->regex, e->subject, 1, pmatch, 0))) ?
                                  e->subject :
                                  e->subject + pmatch[0].rm_eo;
index ebb8c6142252b81af06dece6ae3e11562af24011..8b8ef520e9cb3431d3b7eb60cfab1f911ae04603 100644 (file)
@@ -220,6 +220,8 @@ bool mutt_regexlist_match(struct RegexList *rl, const char *str)
 
   for (; rl; rl = rl->next)
   {
+    if (!rl->regex || rl->regex->regex)
+      continue;
     if (regexec(rl->regex->regex, str, (size_t) 0, (regmatch_t *) 0, (int) 0) == 0)
     {
       mutt_debug(5, "%s matches %s\n", str, rl->regex->pattern);
index 4b8dcebcce08b8a57852ffc87c4e14c676183c48..7a537212bd4d953d34b8868fe1f4985ddace7447 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -320,7 +320,7 @@ char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw)
 
   memset(dest, 0, destlen);
 
-  if (GecosMask)
+  if (GecosMask && GecosMask->regex)
   {
     if (regexec(GecosMask->regex, pw->pw_gecos, 1, pat_match, 0) == 0)
       mutt_str_strfcpy(dest, pw->pw_gecos + pat_match[0].rm_so,
index 309d6d4146d2d612664a4572a00b9cb2c99f0f50..ac5fa88cc34b644210a7d74b8657c3b1d559feda 100644 (file)
@@ -187,7 +187,7 @@ static int pgp_copy_checksig(FILE *fpin, FILE *fpout)
 {
   int rc = -1;
 
-  if (PgpGoodSign)
+  if (PgpGoodSign && PgpGoodSign->regex)
   {
     char *line = NULL;
     int lineno = 0;
@@ -231,7 +231,7 @@ static int pgp_check_decryption_okay(FILE *fpin)
 {
   int rc = -1;
 
-  if (PgpDecryptionOkay)
+  if (PgpDecryptionOkay && PgpDecryptionOkay->regex)
   {
     char *line = NULL;
     int lineno = 0;
diff --git a/pager.c b/pager.c
index fe8ef704dea6e11a8b19ddc38bb1eaef775a1673..9b6156291b664992265cf124de2b21d74ee513ab 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -841,9 +841,9 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n,
   }
   else if (check_sig(buf, line_info, n - 1) == 0)
     line_info[n].type = MT_COLOR_SIGNATURE;
-  else if (QuoteRegex && regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
+  else if (QuoteRegex && QuoteRegex->regex && regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
   {
-    if (Smileys && (regexec(Smileys->regex, buf, 1, smatch, 0) == 0))
+    if (Smileys && Smileys->regex && (regexec(Smileys->regex, buf, 1, smatch, 0) == 0))
     {
       if (smatch[0].rm_so > 0)
       {
@@ -853,7 +853,7 @@ static void resolve_types(char *buf, char *raw, struct Line *line_info, int n,
         c = buf[smatch[0].rm_so];
         buf[smatch[0].rm_so] = 0;
 
-        if (QuoteRegex && regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
+        if (regexec(QuoteRegex->regex, buf, 1, pmatch, 0) == 0)
         {
           if (q_classify && line_info[n].quote == NULL)
             line_info[n].quote = classify_quote(quote_list, buf + pmatch[0].rm_so,
@@ -1490,7 +1490,7 @@ static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info,
         (*last)--;
       goto out;
     }
-    if (QuoteRegex && regexec(QuoteRegex->regex, (char *) fmt, 1, pmatch, 0) == 0)
+    if (QuoteRegex && QuoteRegex->regex && regexec(QuoteRegex->regex, (char *) fmt, 1, pmatch, 0) == 0)
     {
       (*line_info)[n].quote =
           classify_quote(quote_list, (char *) fmt + pmatch[0].rm_so,
diff --git a/parse.c b/parse.c
index 37cf03103755e7d6f5e81e56ad047cf90d6ed407..a2f376283392f9e9890000478664786d5fc0223b 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1280,7 +1280,7 @@ struct Envelope *mutt_read_rfc822_header(FILE *f, struct Header *hdr,
 
       mutt_rfc2047_decode(&e->subject);
 
-      if (ReplyRegex && (regexec(ReplyRegex->regex, e->subject, 1, pmatch, 0) == 0))
+      if (ReplyRegex && ReplyRegex->regex && (regexec(ReplyRegex->regex, e->subject, 1, pmatch, 0) == 0))
         e->real_subj = e->subject + pmatch[0].rm_eo;
       else
         e->real_subj = e->subject;
diff --git a/send.c b/send.c
index 6d6e05061eb05c8a24bd1e5c4ea284cb0e5a9d77..47aabe47a4d8e463319c71fdacd5ae27e0fee74f 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1237,7 +1237,7 @@ static int is_reply(struct Header *reply, struct Header *orig)
 static int search_attach_keyword(char *filename)
 {
   /* Search for the regex in AttachKeyword within a file */
-  if (!AttachKeyword || !QuoteRegex)
+  if (!AttachKeyword || !AttachKeyword->regex || !QuoteRegex || !QuoteRegex->regex)
     return 0;
 
   FILE *attf = mutt_file_fopen(filename, "r");