Build: Make test_{os,parse,dbfn,string} work
[exim.git] / src / src / malware.c
index 9e71afc9b8ec9bd8188bec13727eef5ddc9a27ff..96af1e8c6a49edb1a76bbfa327ed984ef8600cc6 100644 (file)
@@ -2,7 +2,7 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003-2014 */
+/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015 */
 /* License: GPL */
 
 /* Code for calling virus (malware) scanners. Called from acl.c. */
@@ -879,14 +879,14 @@ if (!malware_ok)
 
        for (;;)
          {
-         errno = ETIME;
+         errno = ETIMEDOUT;
          i =  av_buffer+sizeof(av_buffer)-p;
          if ((bread= ip_recv(sock, p, i-1, tmo-time(NULL))) < 0)
            return m_errlog_defer_3(scanent,
              string_sprintf("unable to read result (%s)", strerror(errno)),
              sock);
 
-         for (p[bread] = '\0'; q = Ustrchr(p, '\n'); p = q+1)
+         for (p[bread] = '\0'; (q = Ustrchr(p, '\n')); p = q+1)
            {
            *q = '\0';
 
@@ -1212,7 +1212,7 @@ if (!malware_ok)
 * WITH_OLD_CLAMAV_STREAM is defined.
 * See Exim bug 926 for details.  */
 
-      uschar *p, *vname, *result_tag, *response_end;
+      uschar *p, *vname, *result_tag;
       int bread=0;
       uschar * file_name;
       uschar av_buffer[1024];
@@ -1614,10 +1614,9 @@ if (!malware_ok)
       while (isspace(*--p) && (p > av_buffer))
        *p = '\0';
       if (*p) ++p;
-      response_end = p;
 
       /* colon in returned output? */
-      if((p = Ustrchr(av_buffer,':')) == NULL)
+      if(!(p = Ustrchr(av_buffer,':')))
        return m_errlog_defer(scanent, string_sprintf(
                  "ClamAV returned malformed result (missing colon): %s",
                  av_buffer));
@@ -1881,6 +1880,9 @@ if (!malware_ok)
 
              /* here for any unexpected response from the scanner */
              goto endloop;
+
+           case AVA_DONE:      log_write(0, LOG_PANIC, "%s:%d:%s: should not happen",
+                           __FILE__, __LINE__, __FUNCTION__);
            }
          }
        }