}
static int
-m_scanner_errlog_defer(const uschar * scanner, const uschar * str)
+m_scanner_errlog_defer(const char * scanner, const uschar * str)
{
return malware_errlog_defer(string_sprintf("%s: %s", scanner, str));
}
struct sockaddr_un server;
if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- *errstr = "can't open UNIX socket.";
+ *errstr = US"can't open UNIX socket.";
return -1;
}
int roffset;
const pcre * cre;
- cre = pcre_compile(re, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
+ cre = pcre_compile(CS re, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
if (!cre)
*errstr= string_sprintf("regular expression error in '%s': %s at offset %d",
re, rerror, roffset);
if (!(list_ele = string_nextinlist(list, sep, NULL, 0)))
*errstr = US listerr;
else
- cre = m_pcre_compile(CS list_ele, errstr);
+ cre = m_pcre_compile(CUS list_ele, errstr);
return cre;
}
const char * options_default;
} m_scans[] =
{
- { M_FPROTD, "f-protd", "localhost 10200-10204" },
- { M_DRWEB, "drweb", "/usr/local/drweb/run/drwebd.sock" },
- { M_AVES, "aveserver", "/var/run/aveserver" },
- { M_FSEC, "fsecure", "/var/run/.fsav" },
- { M_KAVD, "kavdaemon", "/var/run/AvpCtl" },
+ { M_FPROTD, "f-protd", CUS"localhost 10200-10204" },
+ { M_DRWEB, "drweb", CUS"/usr/local/drweb/run/drwebd.sock" },
+ { M_AVES, "aveserver", CUS"/var/run/aveserver" },
+ { M_FSEC, "fsecure", CUS"/var/run/.fsav" },
+ { M_KAVD, "kavdaemon", CUS"/var/run/AvpCtl" },
{ M_CMDL, "cmdline", NULL },
- { M_SOPHIE, "sophie", "/var/run/sophie" },
- { M_CLAMD, "clamd", "/tmp/clamd" },
- { M_SOCK, "sock", "/tmp/malware.sock" },
+ { M_SOPHIE, "sophie", CUS"/var/run/sophie" },
+ { M_CLAMD, "clamd", CUS"/tmp/clamd" },
+ { M_SOCK, "sock", CUS"/tmp/malware.sock" },
{ M_MKSD, "mksd", NULL },
{ -1, NULL, NULL } /* end-marker */
};
/* make sure the eml mbox file is spooled up */
if (!(mbox_file = spool_mbox(&mbox_size, faking ? eml_filename : NULL)))
- return malware_errlog_defer("error while creating mbox spool file");
+ return malware_errlog_defer(US"error while creating mbox spool file");
/* none of our current scanners need the mbox
file as a stream, so we can close it right away */
sep = 0;
/* compile the regex, see if it works */
- if (!(re = m_pcre_compile(CS malware_regex, &errstr)))
+ if (!(re = m_pcre_compile(malware_regex, &errstr)))
return malware_errlog_defer(errstr);
/* if av_scanner starts with a dollar, expand it first */
/* find the scanner type from the av_scanner option */
if (!(scanner_name = string_nextinlist(&av_scanner_work, &sep, NULL, 0)))
- return malware_errlog_defer("av_scanner configuration variable is empty");
+ return malware_errlog_defer(US"av_scanner configuration variable is empty");
for (scanent = m_scans; ; scanent++) {
if (!scanent->name)
/* v0.1 - added support for tcp sockets */
/* v0.0 - initial release -- support for unix sockets */
{
- struct sockaddr_un server;
int sock, result;
unsigned int fsize;
uschar * tmpbuf, *drweb_fbuf;
if ((bread = recv(sock, &drweb_vnum, sizeof(drweb_vnum), 0) != sizeof(drweb_vnum))) {
(void)close(sock);
- return drweb_errlog_defer("unable to read the number of viruses");
+ return drweb_errlog_defer(US"unable to read the number of viruses");
}
drweb_vnum = ntohl(drweb_vnum);
int i;
/* setup default virus name */
- malware_name = "unknown";
+ malware_name = US"unknown";
/* set up match regex */
- drweb_re = m_pcre_compile( "infected\\swith\\s*(.+?)$", &errstr);
+ drweb_re = m_pcre_compile(US"infected\\swith\\s*(.+?)$", &errstr);
/* read and concatenate virus names into one string */
for (i=0;i<drweb_vnum;i++)
/* read the size of report */
if ((bread = recv(sock, &drweb_slen, sizeof(drweb_slen), 0) != sizeof(drweb_slen))) {
(void)close(sock);
- return drweb_errlog_defer("cannot read report size");
+ return drweb_errlog_defer(US"cannot read report size");
}
drweb_slen = ntohl(drweb_slen);
tmpbuf = store_get(drweb_slen);
/* read report body */
if ((bread = recv(sock, tmpbuf, drweb_slen, 0)) != drweb_slen) {
(void)close(sock);
- return drweb_errlog_defer("cannot read report string");
+ return drweb_errlog_defer(US"cannot read report string");
}
tmpbuf[drweb_slen] = '\0';
case M_AVES: /* "aveserver" scanner type -------------------------------- */
{
uschar buf[32768];
- struct sockaddr_un server;
int sock;
int result;
}
/* and send it */
- if (m_sock_send(sock, "quit\r\n", 6, &errstr) < 0)
+ if (m_sock_send(sock, US"quit\r\n", 6, &errstr) < 0)
return aves_errlog_defer(errstr);
/* read aveserver's greeting and see if it is ready (2xx greeting) */
case M_FSEC: /* "fsecure" scanner type ---------------------------------- */
{
- struct sockaddr_un server;
int sock, i, j, bread = 0;
uschar * file_name;
uschar av_buffer[1024];
int err = errno;
(void)close(sock);
return fsec_errlog_defer(
- string_sprintf("unable to read answer %d (%s)", i, strerror(errno)));
+ string_sprintf("unable to read answer %d (%s)", i, strerror(err)));
}
for (j=0;j<bread;j++)
if((av_buffer[j]=='\r')||(av_buffer[j]=='\n'))
/* set up match */
/* todo also SUSPICION\t */
- fs_inf = m_pcre_compile("\\S{0,5}INFECTED\\t[^\\t]*\\t([^\\t]+)\\t\\S*$", &errstr);
+ fs_inf = m_pcre_compile(US"\\S{0,5}INFECTED\\t[^\\t]*\\t([^\\t]+)\\t\\S*$", &errstr);
/* read report, linewise */
do {
case M_KAVD: /* "kavdaemon" scanner type -------------------------------- */
{
- struct sockaddr_un server;
int sock;
time_t t;
uschar tmpbuf[1024];
/* wait for result */
if ((bread = recv(sock, tmpbuf, 2, 0) != 2)) {
(void)close(sock);
- return kavd_errlog_defer("unable to read 2 bytes from socket.");
+ return kavd_errlog_defer(US"unable to read 2 bytes from socket.");
}
/* get errorcode from one nibble */
/* improper kavdaemon configuration */
if ( (kav_rc == 5) || (kav_rc == 6) ) {
(void)close(sock);
- return kavd_errlog_defer("please reconfigure kavdaemon to NOT disinfect or remove infected files.");
+ return kavd_errlog_defer(US"please reconfigure kavdaemon to NOT disinfect or remove infected files.");
}
if (kav_rc == 1) {
(void)close(sock);
- return kavd_errlog_defer("reported 'scanning not completed' (code 1).");
+ return kavd_errlog_defer(US"reported 'scanning not completed' (code 1).");
}
if (kav_rc == 7) {
(void)close(sock);
- return kavd_errlog_defer("reported 'kavdaemon damaged' (code 7).");
+ return kavd_errlog_defer(US"reported 'kavdaemon damaged' (code 7).");
}
/* code 8 is not handled, since it is ambigous. It appears mostly on
/* read report size */
if ((bread = recv(sock, &kav_reportlen, 4, 0)) != 4) {
(void)close(sock);
- return kavd_errlog_defer("cannot read report size");
+ return kavd_errlog_defer(US"cannot read report size");
}
/* it's possible that avp returns av_buffer[1] == 1 but the
if (kav_reportlen > 0) {
/* set up match regex, depends on retcode */
kav_re = m_pcre_compile( kav_rc == 3
- ? "suspicion:\\s*(.+?)\\s*$"
- : "infected:\\s*(.+?)\\s*$",
+ ? US"suspicion:\\s*(.+?)\\s*$"
+ : US"infected:\\s*(.+?)\\s*$",
&errstr );
/* read report, linewise */
uschar linebuffer[32767];
int trigger = 0;
uschar *p;
- BOOL fits;
if (!cmdline_scanner)
- return cmdl_errlog_defer("missing commandline specification");
+ return cmdl_errlog_defer(US"missing commandline specification");
/* find scanner output trigger */
cmdline_trigger_re = m_pcre_nextinlist(&av_scanner_work, &sep,
case M_SOPHIE: /* "sophie" scanner type --------------------------------- */
{
int bread = 0;
- struct sockaddr_un server;
int sock;
uschar *p;
uschar * file_name;
malware_name = string_copy(&av_buffer[2]);
}
else if (!strncmp(CS av_buffer, "-1", 2))
- return soph_errlog_defer("scanner reported error");
+ return soph_errlog_defer(US"scanner reported error");
else /* all ok, no virus */
malware_name = NULL;
break;
* See Exim bug 926 for details. */
uschar *p, *vname, *result_tag, *response_end;
- struct sockaddr_un server;
int sock, bread=0;
unsigned int port;
uschar * file_name;
uschar av_buffer[1024];
- uschar *hostname = "";
+ uschar *hostname = US"";
host_item connhost;
uschar *clamav_fbuf;
int clam_fd, result;
/* extract host and port part */
if( sscanf(CS address, "%" MAX_CLAMD_ADDRESS_LENGTH_S "s %u",
this_clamd->tcp_addr, &(this_clamd->tcp_port)) != 2 ) {
- clmd_errlog(string_sprintf("invalid address '%s'", address));
+ clmd_errlog(string_sprintf(US"invalid address '%s'", address));
continue;
}
/* check if we have at least one server */
if (!num_servers)
- return clmd_errlog_defer("no useable server addresses in malware configuration option.");
+ return clmd_errlog_defer(US"no useable server addresses in malware configuration option.");
}
/* See the discussion of response formats below to see why we really don't
/* Lookup the host. This is to ensure that we connect to the same IP
* on both connections (as one host could resolve to multiple ips) */
- sock= m_tcpsocket(CS clamd_address_vector[current_server]->tcp_addr,
+ sock= m_tcpsocket(clamd_address_vector[current_server]->tcp_addr,
clamd_address_vector[current_server]->tcp_port,
&connhost, &errstr);
if (sock >= 0) {
}
if ( num_servers == 0 )
- return clmd_errlog_defer("all servers failed");
+ return clmd_errlog_defer(US"all servers failed");
} else {
if((sock = m_unixsocket(scanner_options, &errstr)) < 0)
CLOSE_SOCKDATA; (void)close(sock); (void)close(clam_fd);
return clmd_errlog_defer(
string_sprintf("can't seek spool file %s: %s",
- eml_filename, strerror(errno)));
+ eml_filename, strerror(err)));
}
lseek(clam_fd, 0, SEEK_SET);
string_sprintf("unable to read from socket (%s)", strerror(errno)));
if (bread == sizeof(av_buffer))
- return clmd_errlog_defer("buffer too small");
+ return clmd_errlog_defer(US"buffer too small");
/* We're now assured of a NULL at the end of av_buffer */
/* Check the result. ClamAV returns one of two result formats.
passing a filename to clamd). */
if (!(*av_buffer))
- return clmd_errlog_defer("ClamAV returned null");
+ return clmd_errlog_defer(US"ClamAV returned null");
/* strip newline at the end (won't be present for zINSTREAM)
(also any trailing whitespace, which shouldn't exist, but we depend upon
if ((sockline_scanner = string_nextinlist(&av_scanner_work, &sep,
NULL, 0)))
{ /* check for no expansions apart from one %s */
- char * s = index(sockline_scanner, '%');
+ char * s = index(CS sockline_scanner, '%');
if (s++)
- if (*s != 's' && *s != '%' || index(s+1, '%'))
- return sock_errlog_defer("unsafe sock scanner call spec");
+ if ((*s != 's' && *s != '%') || index(s+1, '%'))
+ return sock_errlog_defer(US"unsafe sock scanner call spec");
}
else
sockline_scanner = sockline_scanner_default;
string_sprintf("unable to read from socket (%s)", strerror(err)));
if (bread == sizeof(av_buffer))
- return sock_errlog_defer("buffer too small");
+ return sock_errlog_defer(US"buffer too small");
linebuffer = string_copy(av_buffer);
/* try trigger match */
while ((i < 0) && (errno == EINTR));
if (i <= 0) {
close (sock);
- malware_errlog("unable to write to mksd UNIX socket (/var/run/mksd/socket)");
+ malware_errlog(US"unable to write to mksd UNIX socket (/var/run/mksd/socket)");
return -1;
}
do {
if ((i = recv (sock, av_buffer+offset, av_buffer_size-offset, 0)) <= 0) {
close (sock);
- malware_errlog("unable to read from mksd UNIX socket (/var/run/mksd/socket)");
+ malware_errlog(US"unable to read from mksd UNIX socket (/var/run/mksd/socket)");
return -1;
}
/* offset == av_buffer_size -> buffer full */
if (offset == av_buffer_size) {
close (sock);
- malware_errlog("malformed reply received from mksd");
+ malware_errlog(US"malformed reply received from mksd");
return -1;
}
} while (av_buffer[offset-1] != '\n');
if (((p-line) > 5) && (line[3] == ' '))
if (((p = strchr (line+4, ' ')) != NULL) && ((p-line) > 4)) {
*p = '\0';
- malware_name = string_copy(line+4);
+ malware_name = string_copy(US line+4);
return OK;
}
}