Fix up more string types
authorJeremy Harris <jgh146exb@wizmail.org>
Tue, 18 Feb 2014 22:12:22 +0000 (22:12 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Tue, 18 Feb 2014 22:12:22 +0000 (22:12 +0000)
Fix inverted test for empty main malware regex

src/src/malware.c

index f3f624a4c46249cf2c8da047eef3af398c297a75..959ffe72f8d3f017d8c9cd86e1ae50a28cfebb71 100644 (file)
@@ -90,7 +90,7 @@ malware(uschar **listptr)
   int ret;
 
   scan_filename = string_sprintf("%s/scan/%s/%s.eml",
-                                                               spool_directory, message_id, message_id);
+                   spool_directory, message_id, message_id);
   ret = malware_internal(listptr, scan_filename, FALSE);
   if (ret == DEFER) av_failed = TRUE;
 
@@ -342,20 +342,20 @@ typedef enum {M_FPROTD, M_DRWEB, M_AVES, M_FSEC, M_KAVD, M_CMDL,
 static struct scan
 {
   scanner_t    scancode;
-  const char * name;
-  const char * options_default;
+  const uschar * name;
+  const uschar * options_default;
 } m_scans[] =
 {
-  { M_FPROTD,  "f-protd",      CUS"localhost 10200-10204" },
-  { M_DRWEB,   "drweb",        CUS"/usr/local/drweb/run/drwebd.sock" },
-  { M_AVES,    "aveserver",    CUS"/var/run/aveserver" },
-  { M_FSEC,    "fsecure",      CUS"/var/run/.fsav" },
-  { M_KAVD,    "kavdaemon",    CUS"/var/run/AvpCtl" },
-  { M_CMDL,    "cmdline",      NULL },
-  { M_SOPHIE,  "sophie",       CUS"/var/run/sophie" },
-  { M_CLAMD,   "clamd",        CUS"/tmp/clamd" },
-  { M_SOCK,    "sock",         CUS"/tmp/malware.sock" },
-  { M_MKSD,    "mksd",         NULL },
+  { M_FPROTD,  US"f-protd",    US"localhost 10200-10204" },
+  { M_DRWEB,   US"drweb",      US"/usr/local/drweb/run/drwebd.sock" },
+  { M_AVES,    US"aveserver",  US"/var/run/aveserver" },
+  { M_FSEC,    US"fsecure",    US"/var/run/.fsav" },
+  { M_KAVD,    US"kavdaemon",  US"/var/run/AvpCtl" },
+  { M_CMDL,    US"cmdline",    NULL },
+  { M_SOPHIE,  US"sophie",     US"/var/run/sophie" },
+  { M_CLAMD,   US"clamd",      US"/tmp/clamd" },
+  { M_SOCK,    US"sock",       US"/tmp/malware.sock" },
+  { M_MKSD,    US"mksd",       NULL },
   { -1,                NULL,           NULL }          /* end-marker */
 };
 
@@ -392,25 +392,22 @@ malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
 
   /* none of our current scanners need the mbox
      file as a stream, so we can close it right away */
-  /*XXX drweb and clamd do!! */
   (void)fclose(mbox_file);
 
   /* extract the malware regex to match against from the option list */
-  if (!(malware_regex = string_nextinlist(&list, &sep, NULL, 0))) {
+  if (!(malware_regex = string_nextinlist(&list, &sep, NULL, 0)))
+    return FAIL;               /* empty means "don't match anything" */
 
-    /* parse 1st option */
+  /* parse 1st option */
     if ( (strcmpic(malware_regex,US"false") == 0) ||
-         (Ustrcmp(malware_regex,"0") == 0) )
-      return FAIL;             /* explicitly no matching */
-
-    /* special cases (match anything except empty) */
-    if ( (strcmpic(malware_regex,US"true") == 0) ||
-         (Ustrcmp(malware_regex,"*") == 0) ||
-         (Ustrcmp(malware_regex,"1") == 0) )
-      malware_regex = malware_regex_default;
-  }
-  else /* empty means "don't match anything" */
-    return FAIL;
+       (Ustrcmp(malware_regex,"0") == 0) )
+    return FAIL;               /* explicitly no matching */
+
+  /* special cases (match anything except empty) */
+  if ( (strcmpic(malware_regex,US"true") == 0) ||
+       (Ustrcmp(malware_regex,"*") == 0) ||
+       (Ustrcmp(malware_regex,"1") == 0) )
+    malware_regex = malware_regex_default;
 
   /* Reset sep that is set by previous string_nextinlist() call */
   sep = 0;
@@ -609,7 +606,7 @@ malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
        /* wait for result */
        if ((bread = recv(sock, &drweb_rc, sizeof(drweb_rc), 0) != sizeof(drweb_rc))) {
          (void)close(sock);
-         return drweb_errlog_defer("unable to read return code");
+         return drweb_errlog_defer(US"unable to read return code");
        }
        drweb_rc = ntohl(drweb_rc);
 
@@ -908,7 +905,7 @@ malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
          int report_flag = 0;
 
          /* setup default virus name */
-         malware_name = "unknown";
+         malware_name = US"unknown";
 
          report_flag = tmpbuf[ test_byte_order() == LITTLE_MY_ENDIAN ? 1 : 0 ];
 
@@ -1179,14 +1176,14 @@ malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
            /* extract host and port part */
            if( sscanf(CS address, "%" MAX_CLAMD_ADDRESS_LENGTH_S "s %u",
                   this_clamd->tcp_addr, &(this_clamd->tcp_port)) != 2 ) {
-             clmd_errlog(string_sprintf(US"invalid address '%s'", address));
+             clmd_errlog(string_sprintf("invalid address '%s'", address));
              continue;
            }
 
            clamd_address_vector[num_servers] = this_clamd;
            num_servers++;
            if (num_servers >= MAX_CLAMD_SERVERS) {
-             clmd_errlog("More than " MAX_CLAMD_SERVERS_S " clamd servers "
+             clmd_errlog(US"More than " MAX_CLAMD_SERVERS_S " clamd servers "
                    "specified; only using the first " MAX_CLAMD_SERVERS_S );
              break;
            }
@@ -1596,6 +1593,7 @@ malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
        }
        else /* no virus found */
          malware_name = NULL;
+       break;
       }
 
     case M_MKSD: /* "mksd" scanner type ------------------------------------- */
@@ -1778,3 +1776,6 @@ mksd_scan_packed(int sock, uschar *scan_filename)
 }
 
 #endif /*WITH_CONTENT_SCAN*/
+/*
+ * vi: aw ai sw=2
+ */