diff --git a/clamav-devel/ChangeLog b/clamav-devel/ChangeLog index e0fa439b4..f5e5c4303 100644 --- a/clamav-devel/ChangeLog +++ b/clamav-devel/ChangeLog @@ -1,3 +1,7 @@ +Wed Sep 1 03:32:28 CEST 2004 (tk) +---------------------------------- + * libclamav/cvd.c: display warning if loaded database is older than 7 days + Wed Sep 1 02:21:41 CEST 2004 (tk) ---------------------------------- * etc/freshclam.conf: enable DNSDatabaseInfo by default @@ -7,7 +11,7 @@ Tue Aug 31 20:39:34 CEST 2004 (tk) ---------------------------------- * sigtool: add support for *.hdb files in -l; include creation time in seconds in cvd header - * libclamav: do not load Eicar signature (detected with MD5 checksum in + * libclamav: do not load EICAR signature (detected with MD5 checksum in daily.cvd > 472) Tue Aug 31 13:43:11 CEST 2004 (acab) diff --git a/clamav-devel/libclamav/clamav.h b/clamav-devel/libclamav/clamav.h index df7020b43..d698342c3 100644 --- a/clamav-devel/libclamav/clamav.h +++ b/clamav-devel/libclamav/clamav.h @@ -147,6 +147,7 @@ struct cl_cvd { char *md5; /* 6 */ char *dsig; /* 7 */ char *builder; /* 8 */ + int stime; /* 9 */ }; /* file scanning */ diff --git a/clamav-devel/libclamav/cvd.c b/clamav-devel/libclamav/cvd.c index a74267293..513465ca6 100644 --- a/clamav-devel/libclamav/cvd.c +++ b/clamav-devel/libclamav/cvd.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "clamav.h" #include "others.h" @@ -222,6 +223,13 @@ struct cl_cvd *cl_cvdparse(const char *head) return NULL; } + if((pt = cli_strtok(head, 8, ":"))) { + cvd->stime = atoi(pt); + free(pt); + } else + cli_dbgmsg("CVD -> No creation time in seconds (old file format)\n"); + + return cvd; } @@ -236,7 +244,7 @@ struct cl_cvd *cl_cvdhead(const char *file) return NULL; } - if((i=fread(head, 1, 512, fd)) != 512) { + if((i = fread(head, 1, 512, fd)) != 512) { cli_dbgmsg("Short read (%d) while reading CVD head from %s\n", i, file); fclose(fd); return NULL; @@ -259,7 +267,7 @@ void cl_cvdfree(struct cl_cvd *cvd) free(cvd); } -int cli_cvdverify(FILE *fd) +int cli_cvdverify(FILE *fd, struct cl_cvd *cvdpt) { struct cl_cvd *cvd; char *md5, head[513]; @@ -277,6 +285,8 @@ int cli_cvdverify(FILE *fd) if((cvd = cl_cvdparse(head)) == NULL) return CL_ECVD; + if(cvd) + memcpy(cvdpt, cvd, sizeof(struct cl_cvd)); md5 = cli_md5stream(fd); cli_dbgmsg("MD5(.tar.gz) = %s\n", md5); @@ -312,7 +322,7 @@ int cl_cvdverify(const char *file) return CL_EOPEN; } - ret = cli_cvdverify(fd); + ret = cli_cvdverify(fd, NULL); fclose(fd); return ret; @@ -321,17 +331,30 @@ int cl_cvdverify(const char *file) int cli_cvdload(FILE *fd, struct cl_node **root, int *virnum) { char *dir, *tmp, *buffer; + struct cl_cvd cvd; int bytes, ret; const char *tmpdir; FILE *tmpd; + time_t stime; + cli_dbgmsg("in cli_cvdload()\n"); /* verify */ - if((ret = cli_cvdverify(fd))) + if((ret = cli_cvdverify(fd, &cvd))) return ret; + if(cvd.stime) { + time(&stime); + if((int) stime - cvd.stime > 604800) { + cli_warnmsg("**************************************************\n"); + cli_warnmsg("*** The virus database is older than 7 days. ***\n"); + cli_warnmsg("*** Please update it IMMEDIATELY! ***\n"); + cli_warnmsg("**************************************************\n"); + } + } + fseek(fd, 512, SEEK_SET); tmpdir = getenv("TMPDIR");