From f7b639017a889d802b26b61df6b3f1ac46c6f4f0 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Fri, 17 Dec 2004 14:52:43 +0000 Subject: [PATCH] 1. Tidies to get rid of compiler warnings from the merged Exiscan files. 2. Fixed a very old bug that sometimes lost the final 221 message after QUIT. --- doc/doc-misc/WishList | 16 +- doc/doc-txt/ChangeLog | 13 +- doc/doc-txt/NewStuff | 7 +- src/src/EDITME | 33 +-- src/src/acl.c | 4 +- src/src/functions.h | 4 +- src/src/globals.c | 4 +- src/src/header.c | 3 +- src/src/macros.h | 4 +- src/src/malware.c | 471 +++++++++++++++++++++--------------------- src/src/mime.c | 10 +- src/src/receive.c | 4 +- src/src/regex.c | 6 +- src/src/spam.c | 6 +- src/src/spool_mbox.c | 36 ++-- src/src/srs.c | 6 +- src/src/version.c | 4 +- 17 files changed, 329 insertions(+), 302 deletions(-) diff --git a/doc/doc-misc/WishList b/doc/doc-misc/WishList index 391bde978..1704cdbb3 100644 --- a/doc/doc-misc/WishList +++ b/doc/doc-misc/WishList @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-misc/WishList,v 1.14 2004/12/07 14:23:56 ph10 Exp $ +$Cambridge: exim/doc/doc-misc/WishList,v 1.15 2004/12/17 14:52:43 ph10 Exp $ EXIM 4 WISH LIST ---------------- @@ -880,6 +880,11 @@ cleanly. 22-Apr-04: Implemented for domains, addresses, and local parts. Hosts are too messy! + +The only sensible approach seems to be to allow IP address arguments only. +Anything else should be diagnosed as an error. However, if a name appears in +the list, a PTR lookup should be done. This may require a lot of refactoring +in the code. ------------------------------------------------------------------------------ (74) 22-Jul-02 M Extend -bV to do more semantic checking @@ -1826,5 +1831,12 @@ instead of 550, and also vary the defer code. The first digit, however, should remain fixed. In addition to main codes, enhanced status codes (RFC 2034) were requested. (As far as I can tell, they have never been highly popular.) ------------------------------------------------------------------------------ ---- HWM 311 ------------------------------------------------------------------ + +(312) 10-Dec-04 ? Shadow remote transports + +Unless a lot of work is done, this would be restricted to another remote +transport. A similar effect could therefore be achieved with "shadow_hosts" +which are like fallback_hosts but which operate on success. +------------------------------------------------------------------------------ +--- HWM 312 ------------------------------------------------------------------ ---------------------------- End of WishList --------------------------------- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index c35a96f65..110a02f7d 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,10 +1,9 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.42 2004/11/25 15:29:36 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.43 2004/12/17 14:52:44 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- - -Exim version 4.44 +Exim version 4.50 ----------------- 1. Minor wording change to the doc/README.SIEVE file. @@ -180,6 +179,14 @@ Exim version 4.44 43. Did the same fix as 41 above for OpenSSL, which had the same infelicity. +44. The "Exiscan patch" is now merged into the mainline Exim source. + +45. Sometimes the final signoff response after QUIT could fail to get + transmitted in the non-TLS case. Testing !tls_active instead of tls_active + < 0 before doing a fflush(). This bug looks as though it goes back to the + introduction of TLS in release 3.20, but "sometimes" must have been rare + because the tests only now provoked it. + Exim version 4.43 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index b4fda862d..16c9c4653 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.19 2004/11/25 14:31:28 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.20 2004/12/17 14:52:44 ph10 Exp $ New Features in Exim -------------------- @@ -9,7 +9,7 @@ updated when there is a relatively large batch of changes). The doc/ChangeLog file contains a listing of all changes, including bug fixes. -Version 4.44 +Version 4.50 ------------ 1. There is a new build-time option called CONFIGURE_GROUP which works like @@ -219,6 +219,9 @@ Version 4.44 This is helpful when the system filter adds header lines or sets filter variables that are used by the user filter. +19. The Exiscan patch is now merged into the main source. See src/EDITME for + parameters for the build. + Version 4.43 ------------ diff --git a/src/src/EDITME b/src/src/EDITME index aefed22ce..b70c3272b 100644 --- a/src/src/EDITME +++ b/src/src/EDITME @@ -1,4 +1,4 @@ -# $Cambridge: exim/src/src/EDITME,v 1.5 2004/12/16 15:11:47 tom Exp $ +# $Cambridge: exim/src/src/EDITME,v 1.6 2004/12/17 14:52:44 ph10 Exp $ ################################################## # The Exim mail transport agent # @@ -321,42 +321,45 @@ EXIM_MONITOR=eximon.bin # and the MIME ACL. Please read the documentation to learn more about these # features. -#WITH_CONTENT_SCAN=yes +# WITH_CONTENT_SCAN=yes # If you want to use the deprecated "demime" condition in the DATA ACL, # uncomment the line below. Doing so will also explicitly turn on the # WITH_CONTENT_SCAN option. If possible, use the MIME ACL instead of # the "demime" condition. -#WITH_OLD_DEMIME=yes +# WITH_OLD_DEMIME=yes #------------------------------------------------------------------------------ # Compiling Exim with experimental features. These are documented in # experimental-spec.txt. "Experimental" means that the way these features are -# implemented may still change. Backward compatability is not guaranteed. +# implemented may still change. Backward compatibility is not guaranteed. # Uncomment the following lines to add SPF support. You need to have libspf2 # installed on your system (www.libspf2.org). Depending on where it is installed # you may have to edit the CFLAGS and LDFLAGS lines. -#EXPERIMENTAL_SPF=yes -#CFLAGS += -I/usr/local/include -#LDFLAGS += -lspf2 -# Uncommend the following lines to add SRS (Sender rewriting scheme) support. +# EXPERIMENTAL_SPF=yes +# CFLAGS += -I/usr/local/include +# LDFLAGS += -lspf2 + +# Uncomment the following lines to add SRS (Sender rewriting scheme) support. # You need to have libsrs_alt installed on your system (srs.mirtol.com). # Depending on where it is installed you may have to edit the CFLAGS and # LDFLAGS lines. -#EXPERIMENTAL_SRS=yes -#CFLAGS += -I/usr/local/include -#LDFLAGS += -lsrs_alt -# Uncommend the following lines to add Brightmail AntiSpam support. You need +# EXPERIMENTAL_SRS=yes +# CFLAGS += -I/usr/local/include +# LDFLAGS += -lsrs_alt + +# Uncomment the following lines to add Brightmail AntiSpam support. You need # to have the Brightmail client SDK installed. Please check the experimental # documentation for implementation details. You need to edit the CFLAGS and # LDFLAGS lines. -#EXPERIMENTAL_BRIGHTMAIL=yes -#CFLAGS += -I/opt/brightmail/bsdk-6.0/include -#LDFLAGS += -lxml2 -lbmiclient_single -L/opt/brightmail/bsdk-6.0/lib + +# EXPERIMENTAL_BRIGHTMAIL=yes +# CFLAGS += -I/opt/brightmail/bsdk-6.0/include +# LDFLAGS += -lxml2 -lbmiclient_single -L/opt/brightmail/bsdk-6.0/lib diff --git a/src/src/acl.c b/src/src/acl.c index 247ffbb62..128bde552 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/acl.c,v 1.6 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/acl.c,v 1.7 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -248,7 +248,7 @@ static unsigned int cond_forbids[] = { 0, /* delay */ -#ifdef WITH_CONTENT_SCAN +#ifdef WITH_OLD_DEMIME (1<type == '*' && notdel) return FALSE; if (h->text == NULL || strncmpic(h->text, name, len) != 0) return FALSE; return TRUE; diff --git a/src/src/macros.h b/src/src/macros.h index da96396f8..8c76c89b8 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/macros.h,v 1.5 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/macros.h,v 1.6 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -72,7 +72,7 @@ as unsigned. */ a no-op once an SSL session is in progress. */ #ifdef SUPPORT_TLS -#define mac_smtp_fflush() if (!tls_active) fflush(smtp_out); +#define mac_smtp_fflush() if (tls_active < 0) fflush(smtp_out); #else #define mac_smtp_fflush() fflush(smtp_out); #endif diff --git a/src/src/malware.c b/src/src/malware.c index 916480197..82111557c 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/malware.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/malware.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -48,7 +48,7 @@ int malware(uschar **listptr) { uschar *malware_regex; uschar malware_regex_buffer[64]; uschar malware_regex_default[] = ".+"; - unsigned long long mbox_size; + unsigned long mbox_size; FILE *mbox_file; int roffset; const pcre *re; @@ -127,258 +127,257 @@ int malware(uschar **listptr) { return DEFER; }; - /* "drweb" scanner type ----------------------------------------------- */ - /* v0.1 - added support for tcp sockets */ - /* v0.0 - initial release -- support for unix sockets */ - if (strcmpic(scanner_name,US"drweb") == 0) { - uschar *drweb_options; - uschar drweb_options_buffer[1024]; - uschar drweb_options_default[] = "/usr/local/drweb/run/drwebd.sock"; - struct sockaddr_un server; - int sock, port, result, ovector[30]; - unsigned int fsize; - uschar tmpbuf[1024], *drweb_fbuf; - uschar scanrequest[1024]; - uschar drweb_match_string[128]; - int drweb_rc, drweb_cmd, drweb_flags = 0x0000, drweb_fd, - drweb_vnum, drweb_slen, drweb_fin = 0x0000; - unsigned long bread; - uschar hostname[256]; - struct hostent *he; - struct in_addr in; - pcre *drweb_re; + /* "drweb" scanner type ----------------------------------------------- */ + /* v0.1 - added support for tcp sockets */ + /* v0.0 - initial release -- support for unix sockets */ + if (strcmpic(scanner_name,US"drweb") == 0) { + uschar *drweb_options; + uschar drweb_options_buffer[1024]; + uschar drweb_options_default[] = "/usr/local/drweb/run/drwebd.sock"; + struct sockaddr_un server; + int sock, result, ovector[30]; + unsigned int port, fsize; + uschar tmpbuf[1024], *drweb_fbuf; + uschar scanrequest[1024]; + uschar drweb_match_string[128]; + int drweb_rc, drweb_cmd, drweb_flags = 0x0000, drweb_fd, + drweb_vnum, drweb_slen, drweb_fin = 0x0000; + unsigned long bread; + uschar hostname[256]; + struct hostent *he; + struct in_addr in; + pcre *drweb_re; - if ((drweb_options = string_nextinlist(&av_scanner_work, &sep, - drweb_options_buffer, sizeof(drweb_options_buffer))) == NULL) { - /* no options supplied, use default options */ - drweb_options = drweb_options_default; - }; + if ((drweb_options = string_nextinlist(&av_scanner_work, &sep, + drweb_options_buffer, sizeof(drweb_options_buffer))) == NULL) { + /* no options supplied, use default options */ + drweb_options = drweb_options_default; + }; - if (*drweb_options != '/') { + if (*drweb_options != '/') { - /* extract host and port part */ - if( sscanf(CS drweb_options, "%s %u", hostname, &port) != 2 ) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: invalid socket '%s'", drweb_options); - return DEFER; - } + /* extract host and port part */ + if( sscanf(CS drweb_options, "%s %u", hostname, &port) != 2 ) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: invalid socket '%s'", drweb_options); + return DEFER; + } - /* Lookup the host */ - if((he = gethostbyname(CS hostname)) == 0) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: failed to lookup host '%s'", hostname); - return DEFER; - } + /* Lookup the host */ + if((he = gethostbyname(CS hostname)) == 0) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: failed to lookup host '%s'", hostname); + return DEFER; + } - in = *(struct in_addr *) he->h_addr_list[0]; + in = *(struct in_addr *) he->h_addr_list[0]; - /* Open the drwebd TCP socket */ - if ( (sock = ip_socket(SOCK_STREAM, AF_INET)) < 0) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to acquire socket (%s)", - strerror(errno)); - return DEFER; - } + /* Open the drwebd TCP socket */ + if ( (sock = ip_socket(SOCK_STREAM, AF_INET)) < 0) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to acquire socket (%s)", + strerror(errno)); + return DEFER; + } - if (ip_connect(sock, AF_INET, (uschar*)inet_ntoa(in), port, 5) < 0) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: connection to %s, port %u failed (%s)", - inet_ntoa(in), port, strerror(errno)); - return DEFER; - } + if (ip_connect(sock, AF_INET, (uschar*)inet_ntoa(in), port, 5) < 0) { + close(sock); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: connection to %s, port %u failed (%s)", + inet_ntoa(in), port, strerror(errno)); + return DEFER; + } - /* prepare variables */ - drweb_cmd = htonl(DRWEBD_SCAN_CMD); - drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); - snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", - spool_directory, message_id, message_id); + /* prepare variables */ + drweb_cmd = htonl(DRWEBD_SCAN_CMD); + drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); + snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", + spool_directory, message_id, message_id); - /* calc file size */ - drweb_fd = open(CS scanrequest, O_RDONLY); - if (drweb_fd == -1) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: can't open spool file %s: %s", - scanrequest, strerror(errno)); - return DEFER; - } - fsize = lseek(drweb_fd, 0, SEEK_END); - if (fsize == -1) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: can't seek spool file %s: %s", - scanrequest, strerror(errno)); - return DEFER; - } - drweb_slen = htonl(fsize); - lseek(drweb_fd, 0, SEEK_SET); + /* calc file size */ + drweb_fd = open(CS scanrequest, O_RDONLY); + if (drweb_fd == -1) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: can't open spool file %s: %s", + scanrequest, strerror(errno)); + return DEFER; + } + fsize = lseek(drweb_fd, 0, SEEK_END); + if (fsize == -1) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: can't seek spool file %s: %s", + scanrequest, strerror(errno)); + return DEFER; + } + drweb_slen = htonl(fsize); + lseek(drweb_fd, 0, SEEK_SET); - /* send scan request */ - if ((send(sock, &drweb_cmd, sizeof(drweb_cmd), 0) < 0) || - (send(sock, &drweb_flags, sizeof(drweb_flags), 0) < 0) || - (send(sock, &drweb_fin, sizeof(drweb_fin), 0) < 0) || - (send(sock, &drweb_slen, sizeof(drweb_slen), 0) < 0)) { - close(sock); - close(drweb_fd); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to send commands to socket (%s)", drweb_options); - return DEFER; - } + /* send scan request */ + if ((send(sock, &drweb_cmd, sizeof(drweb_cmd), 0) < 0) || + (send(sock, &drweb_flags, sizeof(drweb_flags), 0) < 0) || + (send(sock, &drweb_fin, sizeof(drweb_fin), 0) < 0) || + (send(sock, &drweb_slen, sizeof(drweb_slen), 0) < 0)) { + close(sock); + close(drweb_fd); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to send commands to socket (%s)", drweb_options); + return DEFER; + } - drweb_fbuf = (uschar *) malloc (fsize); - if (!drweb_fbuf) { - close(sock); - close(drweb_fd); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to allocate memory %u for file (%s)", - fsize, scanrequest); - return DEFER; - } + drweb_fbuf = (uschar *) malloc (fsize); + if (!drweb_fbuf) { + close(sock); + close(drweb_fd); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to allocate memory %u for file (%s)", + fsize, scanrequest); + return DEFER; + } - result = read (drweb_fd, drweb_fbuf, fsize); - if (result == -1) { - close(sock); - close(drweb_fd); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: can't read spool file %s: %s", - scanrequest, strerror(errno)); - return DEFER; - } - - /* send file body to socket */ - if (send(sock, drweb_fbuf, fsize, 0) < 0) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to send file body to socket (%s)", drweb_options); - return DEFER; - } - close(drweb_fd); - free(drweb_fbuf); - } - else { - /* open the drwebd UNIX socket */ - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) { - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: can't open UNIX socket"); - return DEFER; - } - server.sun_family = AF_UNIX; - Ustrcpy(server.sun_path, drweb_options); - if (connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to connect to socket (%s). errno=%d", drweb_options, errno); - return DEFER; - } + result = read (drweb_fd, drweb_fbuf, fsize); + if (result == -1) { + close(sock); + close(drweb_fd); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: can't read spool file %s: %s", + scanrequest, strerror(errno)); + return DEFER; + } + + /* send file body to socket */ + if (send(sock, drweb_fbuf, fsize, 0) < 0) { + close(sock); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to send file body to socket (%s)", drweb_options); + return DEFER; + } + close(drweb_fd); + free(drweb_fbuf); + } + else { + /* open the drwebd UNIX socket */ + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) { + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: can't open UNIX socket"); + return DEFER; + } + server.sun_family = AF_UNIX; + Ustrcpy(server.sun_path, drweb_options); + if (connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un)) < 0) { + close(sock); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to connect to socket (%s). errno=%d", drweb_options, errno); + return DEFER; + } - /* prepare variables */ - drweb_cmd = htonl(DRWEBD_SCAN_CMD); - drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); - snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); - drweb_slen = htonl(Ustrlen(scanrequest)); + /* prepare variables */ + drweb_cmd = htonl(DRWEBD_SCAN_CMD); + drweb_flags = htonl(DRWEBD_RETURN_VIRUSES | DRWEBD_IS_MAIL); + snprintf(CS scanrequest, 1024,CS"%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + drweb_slen = htonl(Ustrlen(scanrequest)); - /* send scan request */ - if ((send(sock, &drweb_cmd, sizeof(drweb_cmd), 0) < 0) || - (send(sock, &drweb_flags, sizeof(drweb_flags), 0) < 0) || - (send(sock, &drweb_slen, sizeof(drweb_slen), 0) < 0) || - (send(sock, scanrequest, Ustrlen(scanrequest), 0) < 0) || - (send(sock, &drweb_fin, sizeof(drweb_fin), 0) < 0)) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to send commands to socket (%s)", drweb_options); - return DEFER; - } - } + /* send scan request */ + if ((send(sock, &drweb_cmd, sizeof(drweb_cmd), 0) < 0) || + (send(sock, &drweb_flags, sizeof(drweb_flags), 0) < 0) || + (send(sock, &drweb_slen, sizeof(drweb_slen), 0) < 0) || + (send(sock, scanrequest, Ustrlen(scanrequest), 0) < 0) || + (send(sock, &drweb_fin, sizeof(drweb_fin), 0) < 0)) { + close(sock); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to send commands to socket (%s)", drweb_options); + return DEFER; + } + } - /* wait for result */ - if ((bread = recv(sock, &drweb_rc, sizeof(drweb_rc), 0) != sizeof(drweb_rc))) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to read return code"); - return DEFER; - } - drweb_rc = ntohl(drweb_rc); + /* wait for result */ + if ((bread = recv(sock, &drweb_rc, sizeof(drweb_rc), 0) != sizeof(drweb_rc))) { + close(sock); + log_write(0, LOG_MAIN|LOG_PANIC, + "malware acl condition: drweb: unable to read return code"); + return DEFER; + } + drweb_rc = ntohl(drweb_rc); - if ((bread = recv(sock, &drweb_vnum, sizeof(drweb_vnum), 0) != sizeof(drweb_vnum))) { - close(sock); - log_write(0, LOG_MAIN|LOG_PANIC, - "malware acl condition: drweb: unable to read the number of viruses"); - return DEFER; - } - drweb_vnum = ntohl(drweb_vnum); - - /* "virus(es) found" if virus number is > 0 */ - if (drweb_vnum) - { - int i; - uschar pre_malware_nb[256]; - - malware_name = malware_name_buffer; - - /* setup default virus name */ - Ustrcpy(malware_name_buffer,"unknown"); - - /* read and concatenate virus names into one string */ - for (i=0;i 0 */ + if (drweb_vnum) + { + int i; + uschar pre_malware_nb[256]; + + malware_name = malware_name_buffer; + + /* setup default virus name */ + Ustrcpy(malware_name_buffer,"unknown"); + + /* read and concatenate virus names into one string */ + for (i=0;i= 2) { - pcre_copy_substring(CS tmpbuf, ovector, result, 1, CS pre_malware_nb, 255); - } - /* the first name we just copy to malware_name */ - if (i==0) - Ustrcpy(CS malware_name_buffer, CS pre_malware_nb); - else { - /* concatenate each new virus name to previous */ - int slen = Ustrlen(malware_name_buffer); - if (slen < (slen+Ustrlen(pre_malware_nb))) { - Ustrcat(malware_name_buffer, "/"); - Ustrcat(malware_name_buffer, pre_malware_nb); - } - } - } - } - else { - /* no virus found */ - malware_name = NULL; - }; - close(sock); - } - /* ----------------------------------------------------------------------- */ + /* try matcher on the line, grab substring */ + result = pcre_exec(drweb_re, NULL, CS tmpbuf, Ustrlen(tmpbuf), 0, 0, ovector, 30); + if (result >= 2) { + pcre_copy_substring(CS tmpbuf, ovector, result, 1, CS pre_malware_nb, 255); + } + /* the first name we just copy to malware_name */ + if (i==0) + Ustrcpy(CS malware_name_buffer, CS pre_malware_nb); + else { + /* concatenate each new virus name to previous */ + int slen = Ustrlen(malware_name_buffer); + if (slen < (slen+Ustrlen(pre_malware_nb))) { + Ustrcat(malware_name_buffer, "/"); + Ustrcat(malware_name_buffer, pre_malware_nb); + } + } + } + } + else { + /* no virus found */ + malware_name = NULL; + }; + close(sock); + } + /* ----------------------------------------------------------------------- */ else if (strcmpic(scanner_name,US"aveserver") == 0) { uschar *kav_options; uschar kav_options_buffer[1024]; uschar kav_options_default[] = "/var/run/aveserver"; uschar buf[32768]; - uschar *p; struct sockaddr_un server; int sock; @@ -452,7 +451,10 @@ int malware(uschar **listptr) { uschar file_name[1024]; uschar av_buffer[1024]; pcre *fs_inf; - static uschar *cmdoptions[] = { "CONFIGURE\tARCHIVE\t1\n","CONFIGURE\tTIMEOUT\t0\n","CONFIGURE\tMAXARCH\t5\n","CONFIGURE\tMIME\t1\n" }; + static uschar *cmdoptions[] = { US"CONFIGURE\tARCHIVE\t1\n", + US"CONFIGURE\tTIMEOUT\t0\n", + US"CONFIGURE\tMAXARCH\t5\n", + US"CONFIGURE\tMIME\t1\n" }; malware_name = NULL; if ((fsecure_options = string_nextinlist(&av_scanner_work, &sep, @@ -947,7 +949,8 @@ int malware(uschar **listptr) { uschar clamd_options_default[] = "/tmp/clamd"; uschar *p,*vname; struct sockaddr_un server; - int sock,port,bread=0; + int sock,bread=0; + unsigned int port; uschar file_name[1024]; uschar av_buffer[1024]; uschar hostname[256]; @@ -1058,7 +1061,7 @@ int malware(uschar **listptr) { /* Check the result. ClamAV Returns infected: -> ": FOUND" not-infected: -> ": OK" - error: -> ": ERROR */ + error: -> ": ERROR */ if (!(*av_buffer)) { log_write(0, LOG_MAIN|LOG_PANIC, @@ -1123,7 +1126,7 @@ int malware(uschar **listptr) { sizeof(mksd_options_buffer))) != NULL) { mksd_maxproc = (int) strtol(CS mksd_options, &mksd_options_end, 10); if ((*mksd_options == '\0') || (*mksd_options_end != '\0') || - (mksd_maxproc < 1) || (mksd_maxproc > 32)) { + (mksd_maxproc < 1) || (mksd_maxproc > 32)) { log_write(0, LOG_MAIN|LOG_PANIC, "malware acl condition: mksd: invalid option '%s'", mksd_options); return DEFER; diff --git a/src/src/mime.c b/src/src/mime.c index 1e8deec1b..26caaacb3 100644 --- a/src/src/mime.c +++ b/src/src/mime.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/mime.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/mime.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -25,8 +25,8 @@ uschar *mime_current_boundary = NULL; void mime_set_anomaly(int level, char *text) { mime_anomaly_level = level; - mime_anomaly_text = text; -}; + mime_anomaly_text = US text; +} /************************************************* @@ -240,7 +240,7 @@ uschar *mime_parse_line(uschar *buffer, uschar *encoding, int *num_decoded) { FILE *mime_get_decode_file(uschar *pname, uschar *fname) { - FILE *f; + FILE *f = NULL; uschar *filename; filename = (uschar *)malloc(2048); @@ -519,7 +519,7 @@ int mime_acl_check(FILE *f, struct mime_boundary_context *context, uschar while(1) { /* reset all per-part mime variables */ - mime_anomaly_level = NULL; + mime_anomaly_level = 0; mime_anomaly_text = NULL; mime_boundary = NULL; mime_charset = NULL; diff --git a/src/src/receive.c b/src/src/receive.c index 7b97b4b22..f69e4b673 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.6 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/receive.c,v 1.7 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2743,7 +2743,7 @@ else { FILE *mbox_file; uschar rfc822_file_path[2048]; - unsigned long long mbox_size; + unsigned long mbox_size; header_line *my_headerlist; uschar *user_msg, *log_msg; int mime_part_count_buffer = -1; diff --git a/src/src/regex.c b/src/src/regex.c index 5c008596d..b6d0badb6 100644 --- a/src/src/regex.c +++ b/src/src/regex.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/regex.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/regex.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -32,7 +32,7 @@ int regex(uschar **listptr) { uschar *list = *listptr; uschar *regex_string; uschar regex_string_buffer[1024]; - unsigned long long mbox_size; + unsigned long mbox_size; FILE *mbox_file; pcre *re; pcre_list *re_list_head = NULL; @@ -113,7 +113,7 @@ int regex(uschar **listptr) { do { /* try matcher on the line */ if (pcre_exec(re_list_item->re, NULL, CS linebuffer, - (int)Ustrlen(linebuffer), 0, 0, NULL, 0) >= 0) { + (int)Ustrlen(linebuffer), 0, 0, NULL, 0) >= 0) { Ustrncpy(regex_match_string_buffer, re_list_item->pcre_text, 1023); regex_match_string = regex_match_string_buffer; if (mime_stream == NULL) diff --git a/src/src/spam.c b/src/src/spam.c index 406daef00..3842efdcf 100644 --- a/src/src/spam.c +++ b/src/src/spam.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spam.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/spam.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -26,7 +26,7 @@ int spam(uschar **listptr) { uschar *list = *listptr; uschar *user_name; uschar user_name_buffer[128]; - unsigned long long mbox_size; + unsigned long mbox_size; FILE *mbox_file; int spamd_sock; uschar spamd_buffer[32600]; @@ -188,7 +188,7 @@ int spam(uschar **listptr) { /* now we are connected to spamd on spamd_sock */ snprintf(CS spamd_buffer, sizeof(spamd_buffer), - "REPORT SPAMC/1.2\r\nUser: %s\r\nContent-length: %lld\r\n\r\n", + "REPORT SPAMC/1.2\r\nUser: %s\r\nContent-length: %ld\r\n\r\n", user_name, mbox_size); diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c index c2799f585..bcad17220 100644 --- a/src/src/spool_mbox.c +++ b/src/src/spool_mbox.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_mbox.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/spool_mbox.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -27,7 +27,7 @@ uschar spooled_message_id[17]; /* returns a pointer to the FILE, and puts the size in bytes into mbox_file_size */ -FILE *spool_mbox(unsigned long long *mbox_file_size) { +FILE *spool_mbox(unsigned long *mbox_file_size) { uschar mbox_path[1024]; uschar message_subdir[2]; uschar data_buffer[65535]; @@ -149,24 +149,24 @@ void unspool_mbox(void) { DIR *tempdir; snprintf(CS mbox_path, 1024, "%s/scan/%s", spool_directory, spooled_message_id); - - tempdir = opendir(CS mbox_path); - /* loop thru dir & delete entries */ - n = 0; - do { - entry = readdir(tempdir); - if (entry == NULL) break; - snprintf(CS file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); - if ( (Ustrcmp(entry->d_name,"..") != 0) && (Ustrcmp(entry->d_name,".") != 0) ) { - debug_printf("unspool_mbox(): unlinking '%s'\n", file_path); + + tempdir = opendir(CS mbox_path); + /* loop thru dir & delete entries */ + n = 0; + do { + entry = readdir(tempdir); + if (entry == NULL) break; + snprintf(CS file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); + if ( (Ustrcmp(entry->d_name,"..") != 0) && (Ustrcmp(entry->d_name,".") != 0) ) { + debug_printf("unspool_mbox(): unlinking '%s'\n", file_path); n = unlink(CS file_path); }; - } while (n > -1); - - closedir(tempdir); - - /* remove directory */ - n = rmdir(CS mbox_path); + } while (n > -1); + + closedir(tempdir); + + /* remove directory */ + n = rmdir(CS mbox_path); }; }; } diff --git a/src/src/srs.c b/src/src/srs.c index a1e08c36e..f92c5a574 100644 --- a/src/src/srs.c +++ b/src/src/srs.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/srs.c,v 1.2 2004/12/16 15:11:47 tom Exp $ */ +/* $Cambridge: exim/src/src/srs.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -35,7 +35,7 @@ int eximsrs_init() if(!srs) { - // Check config + /* Check config */ if(!srs_config) { log_write(0, LOG_MAIN | LOG_PANIC, @@ -43,7 +43,7 @@ int eximsrs_init() return DEFER; } - // Get config + /* Get config */ co = 0; if((secret = string_nextinlist(&list, &co, secret_buf, SRS_MAX_SECRET_LENGTH)) == NULL) diff --git a/src/src/version.c b/src/src/version.c index 6391d13bf..839f5bdca 100644 --- a/src/src/version.c +++ b/src/src/version.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/version.c,v 1.2 2004/10/14 11:21:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/version.c,v 1.3 2004/12/17 14:52:44 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -12,7 +12,7 @@ #include "exim.h" -#define THIS_VERSION "4.44" +#define THIS_VERSION "4.45" /* The header file cnumber.h contains a single line containing the -- 2.25.1