]> git.netwichtig.de Git - user/henk/code/exim.git/blobdiff - src/src/malware.c
Safer handling of argument-logging memory of cwd
[user/henk/code/exim.git] / src / src / malware.c
index 479c3db1d97cbc13243df3b31a93867bed27ef66..a5de8a93834253e9ab4781673923193c8c840922 100644 (file)
 #include "exim.h"
 #ifdef WITH_CONTENT_SCAN       /* entire file */
 
-typedef enum {M_FPROTD, M_DRWEB, M_AVES, M_FSEC, M_KAVD, M_CMDL,
-               M_SOPHIE, M_CLAMD, M_SOCK, M_MKSD, M_AVAST, M_FPROT6D} scanner_t;
+typedef enum {
+#ifndef DISABLE_MAL_FFROTD
+       M_FPROTD,
+#endif
+#ifndef DISABLE_MAL_FFROT6D
+       M_FPROT6D,
+#endif
+#ifndef DISABLE_MAL_DRWEB
+       M_DRWEB,
+#endif
+#ifndef DISABLE_MAL_AVE
+       M_AVES,
+#endif
+#ifndef DISABLE_MAL_FSECURE
+       M_FSEC,
+#endif
+#ifndef DISABLE_MAL_KAV
+       M_KAVD,
+#endif
+#ifndef DISABLE_MAL_SOPHIE
+       M_SOPHIE,
+#endif
+#ifndef DISABLE_MAL_CLAM
+       M_CLAMD,
+#endif
+#ifndef DISABLE_MAL_MKS
+       M_MKSD,
+#endif
+#ifndef DISABLE_MAL_AVAST
+       M_AVAST,
+#endif
+#ifndef DISABLE_MAL_SOCK
+       M_SOCK,
+#endif
+#ifndef DISABLE_MAL_CMDLINE
+       M_CMDL,
+#endif
+       } scanner_t;
 typedef enum {MC_NONE, MC_TCP, MC_UNIX, MC_STRM} contype_t;
 static struct scan
 {
@@ -180,12 +216,14 @@ extern uschar spooled_message_id[MESSAGE_ID_LENGTH+1];
 
 /* Some (currently avast only) use backslash escaped whitespace,
 this function undoes these escapes */
+
 static inline void
-unescape(char *p) {
-  uschar *p0;
-  for (; *p; ++p)
-    if (*p == '\\' && (isspace(p[1]) || p[1] == '\\'))
-      for (p0 = p; *p0; ++p0) *p0 = p0[1];
+unescape(uschar *p)
+{
+uschar *p0;
+for (; *p; ++p)
+  if (*p == '\\' && (isspace(p[1]) || p[1] == '\\'))
+    for (p0 = p; *p0; ++p0) *p0 = p0[1];
 }
 
 /* --- malware_*_defer --- */
@@ -1921,14 +1959,13 @@ b_seek:   err = errno;
 #ifndef DISABLE_MAL_AVAST
     case M_AVAST: /* "avast" scanner type ----------------------------------- */
       {
-      int ovector[3*3];
       uschar buf[1024];
       uschar * scanrequest;
       enum {AVA_HELO, AVA_OPT, AVA_RSP, AVA_DONE} avast_stage;
       int nread;
-      int more_data;
       uschar * error_message = NULL;
-      int strict = TRUE;
+      BOOL more_data = FALSE;
+      BOOL strict = TRUE;
 
       /* According to Martin Tuma @avast the protocol uses "escaped
       whitespace", that is, every embedded whitespace is backslash
@@ -2056,7 +2093,7 @@ b_seek:   err = errno;
              if (pcre_exec(ava_re_clean, NULL, CS buf, slen, 0, 0, NULL, 0) == 0)
                break;
 
-              if (malware_name = m_pcre_exec(ava_re_virus, buf))
+              if ((malware_name = m_pcre_exec(ava_re_virus, buf)))
                 {
                 unescape(malware_name);
                 DEBUG(D_acl)
@@ -2066,7 +2103,7 @@ b_seek:   err = errno;
 
               if (strict)           /* treat scanner errors as malware */
                 {
-                if (malware_name = m_pcre_exec(ava_re_error, buf))
+                if ((malware_name = m_pcre_exec(ava_re_error, buf)))
                   {
                   unescape(malware_name);
                   DEBUG(D_acl)
@@ -2093,9 +2130,9 @@ b_seek:   err = errno;
 
       endloop:
 
-      if (nread == -1) error_message = "EOF from scanner";
-      else if (nread < 0) error_message = "timeout from scanner";
-      else if (nread == 0) error_message = "got nothing from scanner";
+      if (nread == -1) error_message = US"EOF from scanner";
+      else if (nread < 0) error_message = US"timeout from scanner";
+      else if (nread == 0) error_message = US"got nothing from scanner";
       else if (buf[0] != '2') error_message = buf;
 
       DEBUG(D_acl) debug_printf_indent("sent to avast QUIT\n");