Check syscall return values.
[exim.git] / src / src / malware.c
index 79e2e382758a23e5e58beaefba78bdbcde51562c..994c62993d26f857f7c1df90ace770588d2faf69 100644 (file)
@@ -131,6 +131,9 @@ malware_in_file(uschar *eml_filename) {
   set, but if that changes, then it should apply to these tests too */
   unspool_mbox();
 
+  /* silence static analysis tools */
+  message_id = NULL;
+
   return ret;
 }
 
@@ -1071,7 +1074,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       cmdline_trigger_re = pcre_compile(CS cmdline_trigger, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
       if (cmdline_trigger_re == NULL) {
         log_write(0, LOG_MAIN|LOG_PANIC,
-                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_trigger_re, rerror, roffset);
+                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_trigger, rerror, roffset);
         return DEFER;
       };
 
@@ -1089,7 +1092,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       cmdline_regex_re = pcre_compile(CS cmdline_regex, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
       if (cmdline_regex_re == NULL) {
         log_write(0, LOG_MAIN|LOG_PANIC,
-                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_regex_re, rerror, roffset);
+                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_regex, rerror, roffset);
         return DEFER;
       };
 
@@ -1211,7 +1214,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
                                           sizeof(sophie_options_buffer))) == NULL) {
         /* no options supplied, use default options */
         sophie_options = sophie_options_default;
-      };
+      }
 
       /* open the sophie socket */
       sock = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -1246,14 +1249,14 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       DEBUG(D_acl) debug_printf("Malware scan: issuing %s scan [%s]\n",
           scanner_name, sophie_options);
 
-      if (write(sock, file_name, Ustrlen(file_name)) < 0) {
+      if (  write(sock, file_name, Ustrlen(file_name)) < 0
+        || write(sock, "\n", 1) != 1
+         ) {
         (void)close(sock);
         log_write(0, LOG_MAIN|LOG_PANIC,
              "malware acl condition: unable to write to sophie UNIX socket (%s)", sophie_options);
         return DEFER;
-      };
-
-      (void)write(sock, "\n", 1);
+      }
 
       /* wait for result */
       memset(av_buffer, 0, sizeof(av_buffer));
@@ -1262,7 +1265,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
         log_write(0, LOG_MAIN|LOG_PANIC,
              "malware acl condition: unable to read from sophie UNIX socket (%s)", sophie_options);
         return DEFER;
-      };
+      }
 
       (void)close(sock);
 
@@ -1280,7 +1283,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       else {
         /* all ok, no virus */
         malware_name = NULL;
-      };
+      }
     }
     /* ----------------------------------------------------------------------- */