#define BIG_MY_ENDIAN 0
#define LITTLE_MY_ENDIAN 1
int test_byte_order(void);
-int test_byte_order() {
- short int word = 0x0001;
- char *byte = (char *) &word;
- return(byte[0] ? LITTLE_MY_ENDIAN : BIG_MY_ENDIAN);
+int
+test_byte_order()
+{
+ short int word = 0x0001;
+ char *byte = (char *) &word;
+ return(byte[0] ? LITTLE_MY_ENDIAN : BIG_MY_ENDIAN);
}
static uschar * malware_name_internal = NULL;
Returns: Exim message processing code (OK, FAIL, DEFER, ...)
where true means malware was found (condition applies)
*/
-int malware(uschar **listptr) {
+int
+malware(uschar **listptr)
+{
uschar scan_filename[1024];
BOOL fits;
int ret;
where true means malware was found (condition applies)
*/
int
-malware_in_file(uschar *eml_filename) {
+malware_in_file(uschar *eml_filename)
+{
uschar *scan_options[2];
uschar message_id_buf[64];
int ret;
Returns: Exim message processing code (OK, FAIL, DEFER, ...)
where true means malware was found (condition applies)
*/
-static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking) {
+static int
+malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
+{
int sep = 0;
uschar *list = *listptr;
uschar *av_scanner_work = av_scanner;
if (send(sock, &scanrequest, Ustrlen(scanrequest)+1, 0) < 0) {
(void)close(sock);
log_write(0, LOG_MAIN|LOG_PANIC,
- "malware acl condition: f-protd: unable to send command to socket (%s)", scanrequest);
+ "%s f-protd: unable to send command to socket (%s)",
+ mal_err, scanrequest);
return DEFER;
}
/* We get a lot of empty lines, so we need this hack to check for any data at all */
while( recv(sock, buf, 1, MSG_PEEK) > 0 ) {
if ( recv_line(sock, buf, 32768) > 0) {
- if ( Ustrstr(buf, US"<detected type=\"") != NULL ) {
+ if ( Ustrstr(buf, US"<detected type=\"") != NULL )
detected = 1;
- } else if ( detected && (strhelper = Ustrstr(buf, US"<name>")) ) {
+ else if ( detected && (strhelper = Ustrstr(buf, US"<name>")) ) {
if ((strhelper2 = Ustrstr(buf, US"</name>")) != NULL) {
*strhelper2 = '\0';
malware_name_internal = string_copy(strhelper+6);
while (recv_line(sock, buf, 32768) > 0) {
debug_printf("aveserver: %s\n", buf);
if (buf[0] == '2') {
- break;
- } else if (buf[0] == '5') {
+ break;
+ } else if (buf[0] == '5') {
/* aveserver is having problems */
log_write(0, LOG_MAIN|LOG_PANIC,
"malware acl condition: unable to scan file %s (Responded: %s).",
- eml_filename, buf);
+ eml_filename, buf);
result = DEFER;
- break;
- } else if (Ustrncmp(buf,"322",3) == 0) {
+ break;
+ } else if (Ustrncmp(buf,"322",3) == 0) {
uschar *p = Ustrchr(&buf[4],' ');
*p = '\0';
malware_name_internal = string_copy(&buf[4]);
}
/* get errorcode from one nibble */
- if (test_byte_order() == LITTLE_MY_ENDIAN) {
- kav_rc = tmpbuf[0] & 0x0F;
- }
- else {
- kav_rc = tmpbuf[1] & 0x0F;
- };
+ kav_rc = tmpbuf[ test_byte_order()==LITTLE_MY_ENDIAN ? 0 : 1 ] & 0x0F;
/* improper kavdaemon configuration */
if ( (kav_rc == 5) || (kav_rc == 6) ) {
int report_flag = 0;
/* setup default virus name */
- malware_name_internal = "unknown";
+ malware_name_internal = string_copy("unknown");
malware_name = malware_name_internal;
- if (test_byte_order() == LITTLE_MY_ENDIAN) {
- report_flag = tmpbuf[1];
- }
- else {
- report_flag = tmpbuf[0];
- };
+ report_flag = tmpbuf[ test_byte_order() == LITTLE_MY_ENDIAN ? 1 : 0 ];
/* read the report, if available */
if( report_flag == 1 ) {
};
(void)fclose(scanner_record);
}
- else {
- /* no virus found */
+ else /* no virus found */
malware_name = NULL;
- };
}
/* ----------------------------------------------------------------------- */
"malware acl condition: malware acl condition: sophie reported error");
return DEFER;
}
- else {
- /* all ok, no virus */
+ else /* all ok, no virus */
malware_name = NULL;
- }
}
/* ----------------------------------------------------------------------- */
/* It would be bad to encounter a virus with "FOUND" in part of the name,
but we should at least be resistant to it. */
p = Ustrrchr(vname, ' ');
- if (p)
- result_tag = p + 1;
- else
- result_tag = vname;
+ result_tag = p ? p+1 : vname;
if (Ustrcmp(result_tag, "FOUND") == 0) {
/* p should still be the whitespace before the result_tag */
/* simple wrapper for reading lines from sockets */
-int recv_line(int sock, uschar *buffer, int size) {
+int
+recv_line(int sock, uschar *buffer, int size)
+{
uschar *p = buffer;
memset(buffer,0,size);
#include <sys/uio.h>
-static int mksd_writev (int sock, struct iovec *iov, int iovcnt)
+static int
+mksd_writev (int sock, struct iovec *iov, int iovcnt)
{
int i;
}
}
-static int mksd_read_lines (int sock, uschar *av_buffer, int av_buffer_size)
+static int
+mksd_read_lines (int sock, uschar *av_buffer, int av_buffer_size)
{
int offset = 0;
int i;
return offset;
}
-static int mksd_parse_line (char *line)
+static int
+mksd_parse_line (char *line)
{
char *p;
switch (*line) {
- case 'O':
- /* OK */
+ case 'O': /* OK */
return OK;
+
case 'E':
- case 'A':
- /* ERR */
+ case 'A': /* ERR */
if ((p = strchr (line, '\n')) != NULL)
- (*p) = '\0';
+ *p = '\0';
log_write(0, LOG_MAIN|LOG_PANIC,
"malware acl condition: mksd scanner failed: %s", line);
return DEFER;
- default:
- /* VIR */
+
+ default: /* VIR */
if ((p = strchr (line, '\n')) != NULL) {
- (*p) = '\0';
+ *p = '\0';
if (((p-line) > 5) && (line[3] == ' '))
if (((p = strchr (line+4, ' ')) != NULL) && ((p-line) > 4)) {
*p = '\0';
}
}
-static int mksd_scan_packed(int sock, uschar *scan_filename)
+static int
+mksd_scan_packed(int sock, uschar *scan_filename)
{
struct iovec iov[3];
const char *cmd = "MSQ\n";
return mksd_parse_line (CS av_buffer);
}
-#endif
+#endif /*WITH_CONTENT_SCAN*/