summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2018-04-02 22:11:57 +0200
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>2018-04-02 22:12:46 +0200
commit91e974f5a855df1ac83e5a6b0acab4453a401ce2 (patch)
treee3177f9e28602a3be184acc35e1d92de9bbc0d24
parenteb445b049c9b78cbe187b9cb3c318d65862d4851 (diff)
Avast: rework interfaceexim-4_91_RC3
-rw-r--r--src/src/malware.c63
1 files changed, 26 insertions, 37 deletions
diff --git a/src/src/malware.c b/src/src/malware.c
index 730a2be22..479c3db1d 100644
--- a/src/src/malware.c
+++ b/src/src/malware.c
@@ -2047,26 +2047,13 @@ b_seek: err = errno;
case AVA_RSP:
- if (isdigit(buf[0]))
- { /* we're done, this is the last response line from the scanner */
- DEBUG(D_acl) debug_printf_indent("sent to avast QUIT\n");
- if (send(sock, "QUIT\n", 5, 0) == -1) /* courtesy */
- return m_panic_defer_3(scanent, CUS callout_address,
- string_sprintf(
- "unable to send quit request to socket (%s): %s",
- scanner_options, strerror(errno)),
- sock);
-
- if (buf[0] != '2') error_message = buf;
- avast_stage = AVA_DONE;
+ if (isdigit(buf[0])) /* We're done */
goto endloop;
- }
- if (malware_name) /* nothing else matters, just read on */
+ if (malware_name) /* Nothing else matters, just read on */
break;
- if (pcre_exec(ava_re_clean, NULL, CS buf, slen,
- 0, 0, ovector, nelem(ovector)) > 0)
+ 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))
@@ -2077,15 +2064,17 @@ b_seek: err = errno;
break;
}
- if (strict && (malware_name = m_pcre_exec(ava_re_error, buf)))
+ if (strict) /* treat scanner errors as malware */
{
- unescape(malware_name);
- DEBUG(D_acl)
- debug_printf_indent("unescaped error message: '%s'\n", malware_name);
- break;
+ if (malware_name = m_pcre_exec(ava_re_error, buf))
+ {
+ unescape(malware_name);
+ DEBUG(D_acl)
+ debug_printf_indent("unescaped error message: '%s'\n", malware_name);
+ break;
+ }
}
-
- if (pcre_exec(ava_re_error, NULL, CS buf, slen, 0, 0, NULL, 0) == 0)
+ else if (pcre_exec(ava_re_error, NULL, CS buf, slen, 0, 0, NULL, 0) == 0)
{
log_write(0, LOG_MAIN, "internal scanner error (ignored): %s", buf);
break;
@@ -2093,7 +2082,7 @@ b_seek: err = errno;
/* here also for any unexpected response from the scanner */
DEBUG(D_acl) debug_printf("avast response not handled: '%s'\n", buf);
- error_message = string_sprintf(string_sprintf("unexpected response from scanner: '%s'", buf));
+
goto endloop;
default: log_write(0, LOG_PANIC, "%s:%d:%s: should not happen",
@@ -2101,23 +2090,23 @@ b_seek: err = errno;
}
}
}
+
endloop:
- switch(avast_stage)
- {
- case AVA_HELO:
- case AVA_OPT:
- case AVA_RSP:
- if (nread == -1) error_message = "EOF from scanner";
- else if (nread < 0) error_message = "timeout from scanner";
+ 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";
+ else if (buf[0] != '2') error_message = buf;
- case AVA_DONE:
- if (error_message)
- return m_panic_defer_3(scanent, CUS callout_address, error_message, sock);
+ DEBUG(D_acl) debug_printf_indent("sent to avast QUIT\n");
+ if (send(sock, "QUIT\n", 5, 0) == -1)
+ return m_panic_defer_3(scanent, CUS callout_address,
+ string_sprintf("unable to send quit request to socket (%s): %s",
+ scanner_options, strerror(errno)), sock);
+
+ if (error_message)
+ return m_panic_defer_3(scanent, CUS callout_address, error_message, sock);
- default: break;
- }
- break;
}
#endif
} /* scanner type switch */