git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@818 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/09/01 10:36:02... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Wed Sep 1 03:32:28 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/cvd.c: display warning if loaded database is older than 7 days |
|
4 |
+ |
|
1 | 5 |
Wed Sep 1 02:21:41 CEST 2004 (tk) |
2 | 6 |
---------------------------------- |
3 | 7 |
* etc/freshclam.conf: enable DNSDatabaseInfo by default |
... | ... |
@@ -7,7 +11,7 @@ Tue Aug 31 20:39:34 CEST 2004 (tk) |
7 | 7 |
---------------------------------- |
8 | 8 |
* sigtool: add support for *.hdb files in -l; include creation time in |
9 | 9 |
seconds in cvd header |
10 |
- * libclamav: do not load Eicar signature (detected with MD5 checksum in |
|
10 |
+ * libclamav: do not load EICAR signature (detected with MD5 checksum in |
|
11 | 11 |
daily.cvd > 472) |
12 | 12 |
|
13 | 13 |
Tue Aug 31 13:43:11 CEST 2004 (acab) |
... | ... |
@@ -29,6 +29,7 @@ |
29 | 29 |
#include <sys/stat.h> |
30 | 30 |
#include <fcntl.h> |
31 | 31 |
#include <zlib.h> |
32 |
+#include <time.h> |
|
32 | 33 |
|
33 | 34 |
#include "clamav.h" |
34 | 35 |
#include "others.h" |
... | ... |
@@ -222,6 +223,13 @@ struct cl_cvd *cl_cvdparse(const char *head) |
222 | 222 |
return NULL; |
223 | 223 |
} |
224 | 224 |
|
225 |
+ if((pt = cli_strtok(head, 8, ":"))) { |
|
226 |
+ cvd->stime = atoi(pt); |
|
227 |
+ free(pt); |
|
228 |
+ } else |
|
229 |
+ cli_dbgmsg("CVD -> No creation time in seconds (old file format)\n"); |
|
230 |
+ |
|
231 |
+ |
|
225 | 232 |
return cvd; |
226 | 233 |
} |
227 | 234 |
|
... | ... |
@@ -236,7 +244,7 @@ struct cl_cvd *cl_cvdhead(const char *file) |
236 | 236 |
return NULL; |
237 | 237 |
} |
238 | 238 |
|
239 |
- if((i=fread(head, 1, 512, fd)) != 512) { |
|
239 |
+ if((i = fread(head, 1, 512, fd)) != 512) { |
|
240 | 240 |
cli_dbgmsg("Short read (%d) while reading CVD head from %s\n", i, file); |
241 | 241 |
fclose(fd); |
242 | 242 |
return NULL; |
... | ... |
@@ -259,7 +267,7 @@ void cl_cvdfree(struct cl_cvd *cvd) |
259 | 259 |
free(cvd); |
260 | 260 |
} |
261 | 261 |
|
262 |
-int cli_cvdverify(FILE *fd) |
|
262 |
+int cli_cvdverify(FILE *fd, struct cl_cvd *cvdpt) |
|
263 | 263 |
{ |
264 | 264 |
struct cl_cvd *cvd; |
265 | 265 |
char *md5, head[513]; |
... | ... |
@@ -277,6 +285,8 @@ int cli_cvdverify(FILE *fd) |
277 | 277 |
if((cvd = cl_cvdparse(head)) == NULL) |
278 | 278 |
return CL_ECVD; |
279 | 279 |
|
280 |
+ if(cvd) |
|
281 |
+ memcpy(cvdpt, cvd, sizeof(struct cl_cvd)); |
|
280 | 282 |
|
281 | 283 |
md5 = cli_md5stream(fd); |
282 | 284 |
cli_dbgmsg("MD5(.tar.gz) = %s\n", md5); |
... | ... |
@@ -312,7 +322,7 @@ int cl_cvdverify(const char *file) |
312 | 312 |
return CL_EOPEN; |
313 | 313 |
} |
314 | 314 |
|
315 |
- ret = cli_cvdverify(fd); |
|
315 |
+ ret = cli_cvdverify(fd, NULL); |
|
316 | 316 |
fclose(fd); |
317 | 317 |
|
318 | 318 |
return ret; |
... | ... |
@@ -321,17 +331,30 @@ int cl_cvdverify(const char *file) |
321 | 321 |
int cli_cvdload(FILE *fd, struct cl_node **root, int *virnum) |
322 | 322 |
{ |
323 | 323 |
char *dir, *tmp, *buffer; |
324 |
+ struct cl_cvd cvd; |
|
324 | 325 |
int bytes, ret; |
325 | 326 |
const char *tmpdir; |
326 | 327 |
FILE *tmpd; |
328 |
+ time_t stime; |
|
329 |
+ |
|
327 | 330 |
|
328 | 331 |
cli_dbgmsg("in cli_cvdload()\n"); |
329 | 332 |
|
330 | 333 |
/* verify */ |
331 | 334 |
|
332 |
- if((ret = cli_cvdverify(fd))) |
|
335 |
+ if((ret = cli_cvdverify(fd, &cvd))) |
|
333 | 336 |
return ret; |
334 | 337 |
|
338 |
+ if(cvd.stime) { |
|
339 |
+ time(&stime); |
|
340 |
+ if((int) stime - cvd.stime > 604800) { |
|
341 |
+ cli_warnmsg("**************************************************\n"); |
|
342 |
+ cli_warnmsg("*** The virus database is older than 7 days. ***\n"); |
|
343 |
+ cli_warnmsg("*** Please update it IMMEDIATELY! ***\n"); |
|
344 |
+ cli_warnmsg("**************************************************\n"); |
|
345 |
+ } |
|
346 |
+ } |
|
347 |
+ |
|
335 | 348 |
fseek(fd, 512, SEEK_SET); |
336 | 349 |
|
337 | 350 |
tmpdir = getenv("TMPDIR"); |