libclamav, freshclam: fix handling of dbs when both daily.cvd and daily.cld

are present in the db directory and ScriptedUpdates are turned off (bb#1739)
0.96
Tomasz Kojm 16 years ago
parent 5ccfa0b76a
commit 284e1ee4ba
  1. 6
      ChangeLog
  2. 7
      freshclam/manager.c
  3. 37
      libclamav/readdb.c
  4. 31
      shared/misc.c

@ -1,3 +1,9 @@
Tue Nov 3 22:50:30 CET 2009 (tk)
---------------------------------
* libclamav, freshclam: fix handling of dbs when both daily.cvd and daily.cld
are present in the db directory and ScriptedUpdates
are turned off (bb#1739)
Tue Nov 3 15:18:14 CET 2009 )tk)
---------------------------------
* libclamav/readdb.c: return error if lsig contains redundant subsigs

@ -1684,6 +1684,13 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
if(unlink(localname))
logg("^Can't unlink the old database file %s. Please remove it manually.\n", localname);
if(!optget(opts, "ScriptedUpdates")->enabled) {
snprintf(localname, sizeof(localname), "%s.cld", dbname);
if(!access(localname, R_OK))
if(unlink(localname))
logg("^Can't unlink the old database file %s. Please remove it manually.\n", localname);
}
logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", newdb, current->version, current->sigs, current->fl, current->builder);
if(flevel < current->fl) {

@ -1692,7 +1692,8 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned
} result;
#endif
char *dbfile;
int ret = CL_EOPEN;
int ret = CL_EOPEN, have_cld;
struct cl_cvd *daily_cld, *daily_cvd;
cli_dbgmsg("Loading databases from %s\n", dirname);
@ -1740,8 +1741,38 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine *engine, unsigned
}
sprintf(dbfile, "%s"PATHSEP"daily.cld", dirname);
if(access(dbfile, R_OK))
sprintf(dbfile, "%s"PATHSEP"daily.cvd", dirname);
have_cld = !access(dbfile, R_OK);
if(have_cld) {
daily_cld = cl_cvdhead(dbfile);
if(!daily_cld) {
cli_errmsg("cli_loaddbdir(): error parsing header of %s\n", dbfile);
free(dbfile);
closedir(dd);
return CL_EMALFDB;
}
}
sprintf(dbfile, "%s"PATHSEP"daily.cvd", dirname);
if(!access(dbfile, R_OK)) {
if(have_cld) {
daily_cvd = cl_cvdhead(dbfile);
if(!daily_cvd) {
cli_errmsg("cli_loaddbdir(): error parsing header of %s\n", dbfile);
free(dbfile);
if(have_cld)
cl_cvdfree(daily_cld);
closedir(dd);
return CL_EMALFDB;
}
if(daily_cld->version > daily_cvd->version)
sprintf(dbfile, "%s"PATHSEP"daily.cld", dirname);
cl_cvdfree(daily_cvd);
}
} else {
sprintf(dbfile, "%s"PATHSEP"daily.cld", dirname);
}
if(have_cld)
cl_cvdfree(daily_cld);
if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) {
free(dbfile);
closedir(dd);

@ -117,6 +117,8 @@ void print_version(const char *dbdir)
char *fdbdir = NULL, *path;
const char *pt;
struct cl_cvd *daily;
time_t db_time;
unsigned int db_version = 0;
if(dbdir)
@ -136,17 +138,32 @@ void print_version(const char *dbdir)
}
sprintf(path, "%s"PATHSEP"daily.cvd", pt);
if(access(path, R_OK))
sprintf(path, "%s"PATHSEP"daily.cld", pt);
if(!access(path, R_OK)) {
daily = cl_cvdhead(path);
if(daily) {
db_version = daily->version;
db_time = daily->stime;
cl_cvdfree(daily);
}
}
sprintf(path, "%s"PATHSEP"daily.cld", pt);
if(!access(path, R_OK)) {
daily = cl_cvdhead(path);
if(daily) {
if(daily->version > db_version) {
db_version = daily->version;
db_time = daily->stime;
}
cl_cvdfree(daily);
}
}
if(!dbdir)
free(fdbdir);
if(!access(path, R_OK) && (daily = cl_cvdhead(path))) {
time_t t = (time_t) daily->stime;
printf("ClamAV %s/%d/%s", get_version(), daily->version, ctime(&t));
cl_cvdfree(daily);
if(db_version) {
printf("ClamAV %s/%u/%s", get_version(), db_version, ctime(&db_time));
} else {
printf("ClamAV %s\n",get_version());
}

Loading…
Cancel
Save