git://git.exim.org
/
users
/
jgh
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c5c11f4
)
Coding style tweaks
author
Jeremy Harris
<jgh146exb@wizmail.org>
Sun, 19 Jan 2014 22:44:55 +0000
(22:44 +0000)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Sun, 19 Jan 2014 22:44:55 +0000
(22:44 +0000)
src/src/malware.c
patch
|
blob
|
history
diff --git
a/src/src/malware.c
b/src/src/malware.c
index fcb72189ef3d3685f7c9c7d35062f53468b9faef..9d459bf3f607521e774f7ec20cc42131180a6a89 100644
(file)
--- a/
src/src/malware.c
+++ b/
src/src/malware.c
@@
-50,10
+50,12
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
#define BIG_MY_ENDIAN 0
#define LITTLE_MY_ENDIAN 1
int test_byte_order(void);
#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;
}
static uschar * malware_name_internal = NULL;
@@
-78,7
+80,9
@@
Arguments:
Returns: Exim message processing code (OK, FAIL, DEFER, ...)
where true means malware was found (condition applies)
*/
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;
uschar scan_filename[1024];
BOOL fits;
int ret;
@@
-116,7
+120,8
@@
Returns: Exim message processing code (OK, FAIL, DEFER, ...)
where true means malware was found (condition applies)
*/
int
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;
uschar *scan_options[2];
uschar message_id_buf[64];
int ret;
@@
-165,7
+170,9
@@
Arguments:
Returns: Exim message processing code (OK, FAIL, DEFER, ...)
where true means malware was found (condition applies)
*/
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;
int sep = 0;
uschar *list = *listptr;
uschar *av_scanner_work = av_scanner;
@@
-338,16
+345,17
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
if (send(sock, &scanrequest, Ustrlen(scanrequest)+1, 0) < 0) {
(void)close(sock);
log_write(0, LOG_MAIN|LOG_PANIC,
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) {
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;
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);
if ((strhelper2 = Ustrstr(buf, US"</name>")) != NULL) {
*strhelper2 = '\0';
malware_name_internal = string_copy(strhelper+6);
@@
-685,15
+693,15
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
while (recv_line(sock, buf, 32768) > 0) {
debug_printf("aveserver: %s\n", buf);
if (buf[0] == '2') {
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).",
/* 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;
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]);
uschar *p = Ustrchr(&buf[4],' ');
*p = '\0';
malware_name_internal = string_copy(&buf[4]);
@@
-924,12
+932,7
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
}
/* get errorcode from one nibble */
}
/* 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) ) {
/* improper kavdaemon configuration */
if ( (kav_rc == 5) || (kav_rc == 6) ) {
@@
-961,15
+964,10
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
int report_flag = 0;
/* setup default virus name */
int report_flag = 0;
/* setup default virus name */
- malware_name_internal =
"unknown"
;
+ malware_name_internal =
string_copy("unknown")
;
malware_name = malware_name_internal;
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 ) {
/* read the report, if available */
if( report_flag == 1 ) {
@@
-1189,10
+1187,8
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
};
(void)fclose(scanner_record);
}
};
(void)fclose(scanner_record);
}
- else {
- /* no virus found */
+ else /* no virus found */
malware_name = NULL;
malware_name = NULL;
- };
}
/* ----------------------------------------------------------------------- */
}
/* ----------------------------------------------------------------------- */
@@
-1280,10
+1276,8
@@
static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
"malware acl condition: malware acl condition: sophie reported error");
return DEFER;
}
"malware acl condition: malware acl condition: sophie reported error");
return DEFER;
}
- else {
- /* all ok, no virus */
+ else /* all ok, no virus */
malware_name = NULL;
malware_name = NULL;
- }
}
/* ----------------------------------------------------------------------- */
}
/* ----------------------------------------------------------------------- */
@@
-1756,10
+1750,7
@@
try_next_server:
/* 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, ' ');
/* 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 */
if (Ustrcmp(result_tag, "FOUND") == 0) {
/* p should still be the whitespace before the result_tag */
@@
-1875,7
+1866,9
@@
try_next_server:
/* simple wrapper for reading lines from sockets */
/* 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);
uschar *p = buffer;
memset(buffer,0,size);
@@
-1895,7
+1888,8
@@
int recv_line(int sock, uschar *buffer, int size) {
#include <sys/uio.h>
#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;
{
int i;
@@
-1924,7
+1918,8
@@
static int mksd_writev (int sock, struct iovec *iov, int iovcnt)
}
}
}
}
-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;
{
int offset = 0;
int i;
@@
-1951,26
+1946,26
@@
static int mksd_read_lines (int sock, uschar *av_buffer, int av_buffer_size)
return offset;
}
return offset;
}
-static int mksd_parse_line (char *line)
+static int
+mksd_parse_line (char *line)
{
char *p;
switch (*line) {
{
char *p;
switch (*line) {
- case 'O':
- /* OK */
+ case 'O': /* OK */
return OK;
return OK;
+
case 'E':
case 'E':
- case 'A':
- /* ERR */
+ case 'A': /* ERR */
if ((p = strchr (line, '\n')) != NULL)
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;
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) {
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';
if (((p-line) > 5) && (line[3] == ' '))
if (((p = strchr (line+4, ' ')) != NULL) && ((p-line) > 4)) {
*p = '\0';
@@
-1985,7
+1980,8
@@
static int mksd_parse_line (char *line)
}
}
}
}
-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";
{
struct iovec iov[3];
const char *cmd = "MSQ\n";
@@
-2009,4
+2005,4
@@
static int mksd_scan_packed(int sock, uschar *scan_filename)
return mksd_parse_line (CS av_buffer);
}
return mksd_parse_line (CS av_buffer);
}
-#endif
+#endif
/*WITH_CONTENT_SCAN*/