From 3dc90d4a30c7ca18bb652ee41a20854d6f9d628a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edvin?= Date: Mon, 23 Feb 2009 12:35:40 +0000 Subject: [PATCH] stop scanning when client disconnects in multiscan mode (bb #1417). git-svn: trunk@4847 --- ChangeLog | 5 +++++ clamd/session.c | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f180f4bb7..d67fbea18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 23 14:10:01 EET 2009 (edwin) +------------------------------------ + * clamd/session.c: stop scanning when client disconnects in + multiscan mode (bb #1417). + Sat Feb 21 21:48:43 EET 2009 (edwin) ------------------------------------ * Makefile.in, clamav-config.h.in, clamav-milter/, clamconf/, diff --git a/clamd/session.c b/clamd/session.c index f6acedab1..9819b1891 100644 --- a/clamd/session.c +++ b/clamd/session.c @@ -40,7 +40,9 @@ #include #ifndef C_WINDOWS #include - +#ifdef HAVE_SYS_SELECT_H +#include +#endif #include #ifdef HAVE_FD_PASSING #ifdef HAVE_SYS_UIO_H @@ -228,6 +230,20 @@ int command(client_conn_t *conn, int *virus) scandata.group = group = thrmgr_group_new(); break; case COMMAND_MULTISCANFILE: + { + fd_set rfds; + struct timeval tv; + + FD_ZERO(&rfds); + FD_SET(conn->sd, &rfds); + tv.tv_sec = tv.tv_usec = 0; + if (select(conn->sd+1, &rfds, NULL, NULL, &tv) > 0 && + FD_ISSET(conn->sd, &rfds)) { + logg("$Client disconnected while multiscan was active!\n"); + thrmgr_group_terminate(conn->group); + return CL_BREAK; + } + } thrmgr_setactivetask(NULL, "MULTISCANFILE"); scandata.group = NULL; scandata.type = TYPE_SCAN;