From a9ccd69a44b1f924cb6fa5bfee76fa0536d1c84a Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Thu, 6 Jul 2006 14:19:50 +0000 Subject: [PATCH] Applied patch from Arkadiusz Miskiewicz to apply a timeout to read operations in malware.c. --- doc/doc-txt/ChangeLog | 5 ++++- src/ACKNOWLEDGMENTS | 5 +++-- src/src/malware.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 33844879d..5d8b2afd5 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.367 2006/07/03 15:39:06 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.368 2006/07/06 14:19:50 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -72,6 +72,9 @@ PH/09 Applied patch from Erik to use select() instead of poll() in spam.c on PH/10 Added more information to debugging output for retry time not reached. +PH/11 Applied patch from Arkadiusz Miskiewicz to apply a timeout to read + operations in malware.c. + Exim version 4.62 ----------------- diff --git a/src/ACKNOWLEDGMENTS b/src/ACKNOWLEDGMENTS index 4090d2409..24c82c973 100644 --- a/src/ACKNOWLEDGMENTS +++ b/src/ACKNOWLEDGMENTS @@ -1,4 +1,4 @@ -$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.50 2006/07/03 15:19:44 ph10 Exp $ +$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.51 2006/07/06 14:19:50 ph10 Exp $ EXIM ACKNOWLEDGEMENTS @@ -20,7 +20,7 @@ relatively small patches. Philip Hazel Lists created: 20 November 2002 -Last updated: 03 July 2006 +Last updated: 06 July 2006 THE OLD LIST @@ -201,6 +201,7 @@ Andreas Metzler Patch for message_id_header_domain Alex Miller Suggested readline() patch Patch for LDAP_RES_SEARCH_REFERENCE handling Support for the DrWeb content scanner +Arkadiusz Miskiewicz Patch to add timeout to reads in malware.c Andreas Mueller Patch for logging uncompleted SMTP transactions Pete Naylor Patch for LDAP TCP connect timeout setting Alexander Newmann Diagnosing and patching obscure and subtle socket bug diff --git a/src/src/malware.c b/src/src/malware.c index 7e3c587c9..fddb19add 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/malware.c,v 1.14 2006/02/22 14:46:44 ph10 Exp $ */ +/* $Cambridge: exim/src/src/malware.c,v 1.15 2006/07/06 14:19:50 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -20,6 +20,10 @@ int mksd_scan_packed(int sock); #define SHUT_WR 1 #endif + +#define MALWARE_TIMEOUT 120 + + #define DRWEBD_SCAN_CMD (1) /* scan file, buffer or diskfile */ #define DRWEBD_RETURN_VIRUSES (1<<0) /* ask daemon return to us viruses names from report */ #define DRWEBD_IS_MAIL (1<<19) /* say to daemon that format is "archive MAIL" */ @@ -557,7 +561,7 @@ int malware(uschar **listptr) { return DEFER; }; - bread = read(sock, av_buffer, sizeof(av_buffer)); + bread = ip_recv(sock, av_buffer, sizeof(av_buffer), MALWARE_TIMEOUT); if (bread >0) av_buffer[bread]='\0'; if (bread < 0) { (void)close(sock); @@ -591,7 +595,7 @@ int malware(uschar **listptr) { i = 0; memset(av_buffer, 0, sizeof(av_buffer)); do { - bread=read(sock, &av_buffer[i], 1); + bread=ip_recv(sock, &av_buffer[i], 1, MALWARE_TIMEOUT); if (bread < 0) { (void)close(sock); log_write(0, LOG_MAIN|LOG_PANIC, @@ -976,7 +980,7 @@ int malware(uschar **listptr) { /* wait for result */ memset(av_buffer, 0, sizeof(av_buffer)); - if ((!(bread = read(sock, av_buffer, sizeof(av_buffer))) > 0)) { + if ((!(bread = ip_recv(sock, av_buffer, sizeof(av_buffer), MALWARE_TIMEOUT)) > 0)) { (void)close(sock); log_write(0, LOG_MAIN|LOG_PANIC, "malware acl condition: unable to read from sophie UNIX socket (%s)", sophie_options); @@ -1098,7 +1102,7 @@ int malware(uschar **listptr) { return DEFER; } memset(av_buffer2, 0, sizeof(av_buffer2)); - bread = read(sock, av_buffer2, sizeof(av_buffer2)); + bread = ip_recv(sock, av_buffer2, sizeof(av_buffer2), MALWARE_TIMEOUT); if (bread < 0) { log_write(0, LOG_MAIN|LOG_PANIC, @@ -1238,7 +1242,7 @@ int malware(uschar **listptr) { /* Read the result */ memset(av_buffer, 0, sizeof(av_buffer)); - bread = read(sock, av_buffer, sizeof(av_buffer)); + bread = ip_recv(sock, av_buffer, sizeof(av_buffer), MALWARE_TIMEOUT); (void)close(sock); if (!(bread > 0)) { -- 2.25.1