git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@97 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2003/11/05 09:53:52... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed Nov 5 01:52:03 CET 2003 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav: zziplib: few files converted to UNIX format (thanks to |
|
4 |
+ Ed Phillips) |
|
5 |
+ |
|
1 | 6 |
Tue Nov 4 13:37:21 CET 2003 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* clamd: yesterday's fix fixed (missing virno variable). Thanks to Nigel. |
... | ... |
@@ -17,10 +17,13 @@ |
17 | 17 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | 18 |
*/ |
19 | 19 |
|
20 |
+/* TODO: Handle SIGALRM more gently */ |
|
21 |
+ |
|
20 | 22 |
#include <stdio.h> |
21 | 23 |
#include <stdlib.h> |
22 | 24 |
#include <unistd.h> |
23 | 25 |
#include <string.h> |
26 |
+#include <signal.h> |
|
24 | 27 |
#include <sys/types.h> |
25 | 28 |
#include <sys/stat.h> |
26 | 29 |
#include <fcntl.h> |
... | ... |
@@ -34,6 +37,7 @@ |
34 | 34 |
#include "defaults.h" |
35 | 35 |
#include "freshclam.h" |
36 | 36 |
|
37 |
+#define TIMEOUT 1200 |
|
37 | 38 |
|
38 | 39 |
void freshclam(struct optstruct *opt) |
39 | 40 |
{ |
... | ... |
@@ -154,11 +158,21 @@ void freshclam(struct optstruct *opt) |
154 | 154 |
|
155 | 155 |
} |
156 | 156 |
|
157 |
+void d_timeout(int sig) |
|
158 |
+{ |
|
159 |
+ mprintf("@Maximal time (%d seconds) reached.\n", TIMEOUT); |
|
160 |
+ exit(1); |
|
161 |
+} |
|
162 |
+ |
|
157 | 163 |
int download(struct optstruct *opt) |
158 | 164 |
{ |
159 | 165 |
int ret = 0; |
160 | 166 |
mirrors *m = NULL, *h = NULL; |
161 | 167 |
int mirror_used = 0; |
168 |
+ struct sigaction sigalrm; |
|
169 |
+ |
|
170 |
+ sigalrm.sa_handler = d_timeout; |
|
171 |
+ sigaction(SIGALRM, &sigalrm, NULL); |
|
162 | 172 |
|
163 | 173 |
/* |
164 | 174 |
* There's an error in __nss_hostname_digits_dots () from /lib/libc.so.6 |
... | ... |
@@ -171,7 +185,11 @@ int download(struct optstruct *opt) |
171 | 171 |
|
172 | 172 |
while(m != NULL) |
173 | 173 |
{ |
174 |
- if((ret = downloadmanager(opt, m->mirror)) == 0) |
|
174 |
+ alarm(TIMEOUT); |
|
175 |
+ ret = downloadmanager(opt, m->mirror); |
|
176 |
+ alarm(0); |
|
177 |
+ |
|
178 |
+ if(ret == 0) |
|
175 | 179 |
{ |
176 | 180 |
if(mirror_used) |
177 | 181 |
{ |
... | ... |
@@ -65,7 +65,7 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
65 | 65 |
else if(ret == 0) |
66 | 66 |
updated = 1; |
67 | 67 |
|
68 |
- /* if ipaddr[0] != 0 it will use ipaddr to connect to the web host */ |
|
68 |
+ /* if ipaddr[0] != 0 it will use it to connect to the web host */ |
|
69 | 69 |
if((ret = downloaddb(DB2NAME, "daily.cvd", hostname, ipaddr, &signo, opt)) > 50) |
70 | 70 |
return ret; |
71 | 71 |
else if(ret == 0) |