Cheap method to follow redis cluster MOVED replies
[exim.git] / src / src / malware.c
index 27bcc92255c6a94afb87b4017fed585dcceec7ad..5b9d5ad582614068615b880b1367db02f81ac44a 100644 (file)
@@ -4,7 +4,7 @@
 
 /* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015
  * License: GPL
- * Copyright (c) The Exim Maintainers 2017 - 2018
+ * Copyright (c) The Exim Maintainers 2015 - 2018
  */
 
 /* Code for calling virus (malware) scanners. Called from acl.c. */
@@ -70,8 +70,9 @@ static struct scan
 void
 features_malware(void)
 {
-struct scan * sc;
-uschar * s, * t;
+const struct scan * sc;
+const uschar * s;
+uschar * t;
 uschar buf[64];
 
 spf(buf, sizeof(buf), US"_HAVE_MALWARE_");
@@ -1276,7 +1277,7 @@ badseek:  err = errno;
       sep = pclose(scanner_out);
       signal(SIGCHLD,eximsigchld); signal(SIGPIPE,eximsigpipe);
       if (sep != 0)
-         return m_errlog_defer(scanent, NULL, 
+         return m_errlog_defer(scanent, NULL,
              sep == -1
              ? string_sprintf("running scanner failed: %s", strerror(sep))
              : string_sprintf("scanner returned error code: %d", sep));
@@ -1431,13 +1432,13 @@ badseek:  err = errno;
          sublist = scanner_options;
          if (!(cd->hostspec = string_nextinlist(&sublist, &subsep, NULL, 0)))
            {
-           (void) m_errlog_defer(scanent, NULL, 
+           (void) m_errlog_defer(scanent, NULL,
                      string_sprintf("missing address: '%s'", scanner_options));
            continue;
            }
          if (!(s = string_nextinlist(&sublist, &subsep, NULL, 0)))
            {
-           (void) m_errlog_defer(scanent, NULL, 
+           (void) m_errlog_defer(scanent, NULL,
                      string_sprintf("missing port: '%s'", scanner_options));
            continue;
            }
@@ -1967,15 +1968,17 @@ b_seek:   err = errno;
                    0, 0, ovector, nelem(ovector)) > 0)
                break;
 
-             if ((malware_name = m_pcre_exec(ava_re_virus, buf)))
+             if (  !malware_name
+                && (malware_name = m_pcre_exec(ava_re_virus, buf)))
                { /* remove backslash in front of [whitespace|backslash] */
                uschar * p, * p0;
                for (p = malware_name; *p; ++p)
                  if (*p == '\\' && (isspace(p[1]) || p[1] == '\\'))
                    for (p0 = p; *p0; ++p0) *p0 = p0[1];
 
-               avast_stage = AVA_DONE;
-               goto endloop;
+               DEBUG(D_acl)
+                 debug_printf_indent("unescaped m-name: '%s'\n", malware_name);
+               break;
                }
 
              if (Ustrncmp(buf, "200 SCAN OK", 11) == 0)
@@ -1986,15 +1989,14 @@ b_seek:   err = errno;
                              "unable to send quit request to socket (%s): %s",
                              scanner_options, strerror(errno)),
                              sock);
-               malware_name = NULL;
+
                avast_stage = AVA_DONE;
-               goto endloop;
                }
 
-             /* here for any unexpected response from the scanner */
+             /* here also for any unexpected response from the scanner */
              goto endloop;
 
-           case AVA_DONE:      log_write(0, LOG_PANIC, "%s:%d:%s: should not happen",
+           default:    log_write(0, LOG_PANIC, "%s:%d:%s: should not happen",
                            __FILE__, __LINE__, __FUNCTION__);
            }
          }