(1) Added $host_lookup_deferred.
[exim.git] / src / src / malware.c
index 4abf7d1f92723d63aab7327b909237ef646732cd..9e32ed59fa2c17cb4bc9e92cfb197a810a34c933 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/malware.c,v 1.5 2005/01/11 08:55:29 tom Exp $ */
+/* $Cambridge: exim/src/src/malware.c,v 1.6 2005/01/13 10:09:36 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -391,10 +391,10 @@ int malware(uschar **listptr) {
                         * DERR_CRC_ERROR, DERR_READSOCKET, DERR_WRITE_ERR
                         * and others are ignored */
                        if (drweb_s) {
-                               log_write(0, LOG_MAIN|LOG_PANIC,
-                                       "malware acl condition: drweb: drweb daemon retcode 0x%x (%s)", drweb_rc, drweb_s);
+                               log_write(0, LOG_MAIN|LOG_PANIC,
+                                       "malware acl condition: drweb: drweb daemon retcode 0x%x (%s)", drweb_rc, drweb_s);
                                close(sock);
-                               return DEFER;
+                               return DEFER;
                        }
                        /* no virus found */
                        malware_name = NULL;
@@ -971,7 +971,7 @@ int malware(uschar **listptr) {
     
 
     /* "clamd" scanner type ------------------------------------------------- */
-    /* This code was contributed by David Saez <david@ols.es> */
+    /* This code was contributed by David Saez */
     else if (strcmpic(scanner_name,US"clamd") == 0) {
       uschar *clamd_options;
       uschar clamd_options_buffer[1024];
@@ -1086,7 +1086,7 @@ int malware(uschar **listptr) {
           }
     
           av_buffer2[bread] = '\0';
-          if( sscanf(CS av_buffer2, "PORT %hu\n", &port) != 1 ) {
+          if( sscanf(CS av_buffer2, "PORT %u\n", &port) != 1 ) {
             log_write(0, LOG_MAIN|LOG_PANIC,
                     "malware acl condition: clamd: Expected port information from clamd, got '%s'", av_buffer2);
             return DEFER;
@@ -1107,57 +1107,57 @@ int malware(uschar **listptr) {
             return DEFER;
           }
 
-         snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml",
+         snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml",
            spool_directory, message_id, message_id);
   
-         /* calc file size */
-         clam_fd = open(CS scanrequest, O_RDONLY);
-         if (clam_fd == -1) {
-           log_write(0, LOG_MAIN|LOG_PANIC,
-                   "malware acl condition: clamd: can't open spool file %s: %s", 
-                   scanrequest, strerror(errno));
-           return DEFER; 
-         }
+         /* calc file size */
+         clam_fd = open(CS scanrequest, O_RDONLY);
+         if (clam_fd == -1) {
+           log_write(0, LOG_MAIN|LOG_PANIC,
+                   "malware acl condition: clamd: can't open spool file %s: %s", 
+                   scanrequest, strerror(errno));
+           return DEFER; 
+         }
          fsize = lseek(clam_fd, 0, SEEK_END);
-         if (fsize == -1) {
-           log_write(0, LOG_MAIN|LOG_PANIC,
-                   "malware acl condition: clamd: can't seek spool file %s: %s", 
-                   scanrequest, strerror(errno));
-           return DEFER; 
-         }
-         lseek(clam_fd, 0, SEEK_SET);
+         if (fsize == -1) {
+           log_write(0, LOG_MAIN|LOG_PANIC,
+                   "malware acl condition: clamd: can't seek spool file %s: %s", 
+                   scanrequest, strerror(errno));
+           return DEFER; 
+         }
+         lseek(clam_fd, 0, SEEK_SET);
   
-         clamav_fbuf = (uschar *) malloc (fsize);
+         clamav_fbuf = (uschar *) malloc (fsize);
          if (!clamav_fbuf) {
            close(sockData);
-           close(clam_fd);
-           log_write(0, LOG_MAIN|LOG_PANIC,
+           close(clam_fd);
+           log_write(0, LOG_MAIN|LOG_PANIC,
                    "malware acl condition: clamd: unable to allocate memory %u for file (%s)", 
-                   fsize, scanrequest);
-           return DEFER;
-         }
+                   fsize, scanrequest);
+           return DEFER;
+         }
   
-         result = read (clam_fd, clamav_fbuf, fsize);
-         if (result == -1) {
-           close(sockData);
-           close(clam_fd);
-           free(clamav_fbuf);
-           log_write(0, LOG_MAIN|LOG_PANIC,
-                   "malware acl condition: clamd: can't read spool file %s: %s",
-                   scanrequest, strerror(errno));
-           return DEFER; 
-         }
-         close(clam_fd);
+         result = read (clam_fd, clamav_fbuf, fsize);
+         if (result == -1) {
+           close(sockData);
+           close(clam_fd);
+           free(clamav_fbuf);
+           log_write(0, LOG_MAIN|LOG_PANIC,
+                   "malware acl condition: clamd: can't read spool file %s: %s",
+                   scanrequest, strerror(errno));
+           return DEFER; 
+         }
+         close(clam_fd);
 
-         /* send file body to socket */
-         if (send(sockData, clamav_fbuf, fsize, 0) < 0) {
-           close(sockData);
-           free(clamav_fbuf);
-           log_write(0, LOG_MAIN|LOG_PANIC,
-             "malware acl condition: clamd: unable to send file body to socket (%s:%u)", hostname, port);
-           return DEFER;
-         }
-         free(clamav_fbuf);
+         /* send file body to socket */
+         if (send(sockData, clamav_fbuf, fsize, 0) < 0) {
+           close(sockData);
+           free(clamav_fbuf);
+           log_write(0, LOG_MAIN|LOG_PANIC,
+             "malware acl condition: clamd: unable to send file body to socket (%s:%u)", hostname, port);
+           return DEFER;
+         }
+         free(clamav_fbuf);
           close(sockData);
         }
       }