[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. 99ae9353f6834da0cb73f59f4b32d1f0ae1263fa
Stephen Gran
steve at lobefin.net
Thu Sep 4 12:36:39 UTC 2008
The following commit has been merged in the debian/unstable branch:
commit c2f68c8cc9b5e9b6ba0d01616ac1b5c251db1532
Author: Stephen Gran <steve at lobefin.net>
Date: Thu Sep 4 13:25:15 2008 +0100
Revert "libclamav: faster loading of uncompressed .cld files, also fixes bb#1064"
This reverts commit eaed8ae0571dc86edac0703be73fab6908c6b5f5.
diff --git a/ChangeLog b/ChangeLog
index dd1afed..08c8e2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,3 @@
-Tue Jul 1 13:41:49 CEST 2008 (tk)
-----------------------------------
- * libclamav: faster loading of uncompressed .cld files, also fixes bb#1064
-
Mon Jun 30 21:28:23 EEST 2008 (edwin)
------------------------------------
* merge r3816 from trunk (bb #947, AIX name collisions)
diff --git a/libclamav/cvd.c b/libclamav/cvd.c
index e10e396..a900347 100644
--- a/libclamav/cvd.c
+++ b/libclamav/cvd.c
@@ -184,14 +184,9 @@ static int cli_tgzload(int fd, struct cl_engine **engine, unsigned int *signo, u
char block[TAR_BLOCKSIZE];
int nread, fdd, ret;
unsigned int type, size, pad, compr = 1;
- off_t off;
- struct cli_dbio dbio;
+ gzFile *infile;
+ z_off_t off;
-#define CLOSE_DBIO \
- if(compr) \
- gzclose(dbio.gzs); \
- else \
- fclose(dbio.fs)
cli_dbgmsg("in cli_tgzload()\n");
@@ -202,38 +197,31 @@ static int cli_tgzload(int fd, struct cl_engine **engine, unsigned int *signo, u
if(!strncmp(block, "COPYING", 7))
compr = 0;
- lseek(fd, 512, SEEK_SET);
-
if((fdd = dup(fd)) == -1) {
cli_errmsg("cli_tgzload: Can't duplicate descriptor %d\n", fd);
return CL_EIO;
}
- if(compr) {
- if((dbio.gzs = gzdopen(fdd, "rb")) == NULL) {
- cli_errmsg("cli_tgzload: Can't gzdopen() descriptor %d, errno = %d\n", fdd, errno);
- return CL_EIO;
- }
- } else {
- if((dbio.fs = fdopen(fdd, "rb")) == NULL) {
- cli_errmsg("cli_tgzload: Can't fdopen() descriptor %d, errno = %d\n", fdd, errno);
- return CL_EIO;
- }
+ lseek(fdd, 512, SEEK_SET);
+
+ if((infile = gzdopen(fdd, "rb")) == NULL) {
+ cli_errmsg("cli_tgzload: Can't gzdopen() descriptor %d, errno = %d\n", fdd, errno);
+ return CL_EIO;
}
+ if(!compr)
+ gzseek(infile, 512, SEEK_SET);
+
while(1) {
- if(compr)
- nread = gzread(dbio.gzs, block, TAR_BLOCKSIZE);
- else
- nread = fread(block, 1, TAR_BLOCKSIZE, dbio.fs);
+ nread = gzread(infile, block, TAR_BLOCKSIZE);
if(!nread)
break;
if(nread != TAR_BLOCKSIZE) {
cli_errmsg("cli_tgzload: Incomplete block read\n");
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
}
@@ -245,7 +233,7 @@ static int cli_tgzload(int fd, struct cl_engine **engine, unsigned int *signo, u
if(strchr(name, '/')) {
cli_errmsg("cli_tgzload: Slash separators are not allowed in CVD\n");
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
}
@@ -257,11 +245,11 @@ static int cli_tgzload(int fd, struct cl_engine **engine, unsigned int *signo, u
break;
case '5':
cli_errmsg("cli_tgzload: Directories are not supported in CVD\n");
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
default:
cli_errmsg("cli_tgzload: Unknown type flag '%c'\n", type);
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
}
@@ -270,41 +258,30 @@ static int cli_tgzload(int fd, struct cl_engine **engine, unsigned int *signo, u
if((sscanf(osize, "%o", &size)) == 0) {
cli_errmsg("cli_tgzload: Invalid size in header\n");
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
}
- dbio.size = size;
/* cli_dbgmsg("cli_tgzload: Loading %s, size: %u\n", name, size); */
- if(compr)
- off = (off_t) gzseek(dbio.gzs, 0, SEEK_CUR);
- else
- off = ftell(dbio.fs);
-
+ off = gzseek(infile, 0, SEEK_CUR);
if(CLI_DBEXT(name)) {
- ret = cli_load(name, engine, signo, options, &dbio);
+ ret = cli_load(name, engine, signo, options, infile, size);
if(ret) {
cli_errmsg("cli_tgzload: Invalid size in header\n");
- CLOSE_DBIO;
+ gzclose(infile);
return CL_EMALFDB;
}
}
pad = size % TAR_BLOCKSIZE ? (TAR_BLOCKSIZE - (size % TAR_BLOCKSIZE)) : 0;
- if(compr) {
- if(off == gzseek(dbio.gzs, 0, SEEK_CUR))
- gzseek(dbio.gzs, size + pad, SEEK_CUR);
- else if(pad)
- gzseek(dbio.gzs, pad, SEEK_CUR);
- } else {
- if(off == ftell(dbio.fs))
- fseek(dbio.fs, size + pad, SEEK_CUR);
- else if(pad)
- fseek(dbio.fs, pad, SEEK_CUR);
- }
+ if(off == gzseek(infile, 0, SEEK_CUR))
+ gzseek(infile, size + pad, SEEK_CUR);
+ else if(pad)
+ gzseek(infile, pad, SEEK_CUR);
+
}
- CLOSE_DBIO;
- return CL_SUCCESS;
+ gzclose(infile);
+ return 0;
}
struct cl_cvd *cl_cvdparse(const char *head)
diff --git a/libclamav/cvd.h b/libclamav/cvd.h
index 3c99a32..69aec76 100644
--- a/libclamav/cvd.h
+++ b/libclamav/cvd.h
@@ -22,15 +22,8 @@
#define __CVD_H
#include <stdio.h>
-#include <zlib.h>
#include "clamav.h"
-struct cli_dbio {
- gzFile *gzs;
- FILE *fs;
- unsigned int size;
-};
-
int cli_cvdload(FILE *fs, struct cl_engine **engine, unsigned int *signo, short warn, unsigned int options, unsigned int cld);
int cli_untgz(int fd, const char *destdir);
diff --git a/libclamav/dconf.c b/libclamav/dconf.c
index b195a83..b6472f1 100644
--- a/libclamav/dconf.c
+++ b/libclamav/dconf.c
@@ -263,7 +263,7 @@ static int chkflevel(const char *entry, int field)
return 1;
}
-int cli_dconf_load(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio)
+int cli_dconf_load(FILE *fs, struct cl_engine **engine, unsigned int options, gzFile *gzs, unsigned int gzrsize)
{
char buffer[FILEBUFF];
unsigned int line = 0;
@@ -279,7 +279,7 @@ int cli_dconf_load(FILE *fs, struct cl_engine **engine, unsigned int options, st
dconf = (struct cli_dconf *) (*engine)->dconf;
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
cli_chomp(buffer);
diff --git a/libclamav/dconf.h b/libclamav/dconf.h
index b5a9afa..171c8ed 100644
--- a/libclamav/dconf.h
+++ b/libclamav/dconf.h
@@ -27,7 +27,6 @@
#include "clamav.h"
#include "cltypes.h"
-#include "cvd.h"
struct cli_dconf {
uint32_t pe;
@@ -97,5 +96,5 @@ struct cli_dconf {
struct cli_dconf *cli_dconf_init(void);
void cli_dconf_print(struct cli_dconf *dconf);
-int cli_dconf_load(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio);
+int cli_dconf_load(FILE *fs, struct cl_engine **engine, unsigned int options, gzFile *gzs, unsigned int gzrsize);
#endif
diff --git a/libclamav/readdb.c b/libclamav/readdb.c
index f061465..af103a8 100644
--- a/libclamav/readdb.c
+++ b/libclamav/readdb.c
@@ -368,7 +368,7 @@ static int cli_initroots(struct cl_engine *engine, unsigned int options)
return CL_SUCCESS;
}
-char *cli_dbgets(char *buff, unsigned int size, FILE *fs, struct cli_dbio *dbio)
+char *cli_dbgets(char *buff, unsigned int size, FILE *fs, gzFile *gzs, unsigned int *gzrsize)
{
if(fs) {
return fgets(buff, size, fs);
@@ -377,16 +377,12 @@ char *cli_dbgets(char *buff, unsigned int size, FILE *fs, struct cli_dbio *dbio)
char *pt;
unsigned int bs;
- if(!dbio->size)
+ if(!*gzrsize)
return NULL;
- bs = dbio->size < size ? dbio->size + 1 : size;
- if(dbio->gzs)
- pt = gzgets(dbio->gzs, buff, bs);
- else
- pt = fgets(buff, bs, dbio->fs);
-
- dbio->size -= strlen(buff);
+ bs = *gzrsize < size ? *gzrsize + 1 : size;
+ pt = gzgets(gzs, buff, bs);
+ *gzrsize -= strlen(buff);
if(!pt)
cli_errmsg("cli_dbgets: Preliminary end of data\n");
return pt;
@@ -414,7 +410,7 @@ static int cli_chkign(const struct cli_ignored *ignored, const char *dbname, uns
return 0;
}
-static int cli_loaddb(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned int options, struct cli_dbio *dbio, const char *dbname)
+static int cli_loaddb(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned int options, gzFile *gzs, unsigned int gzrsize, const char *dbname)
{
char buffer[FILEBUFF], *pt, *start;
unsigned int line = 0, sigs = 0;
@@ -434,7 +430,7 @@ static int cli_loaddb(FILE *fs, struct cl_engine **engine, unsigned int *signo,
root = (*engine)->root[0];
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
cli_chomp(buffer);
@@ -478,7 +474,7 @@ static int cli_loaddb(FILE *fs, struct cl_engine **engine, unsigned int *signo,
return CL_SUCCESS;
}
-static int cli_loadwdb(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio)
+static int cli_loadwdb(FILE *fs, struct cl_engine **engine, unsigned int options, gzFile *gzs, unsigned int gzrsize)
{
int ret = 0;
@@ -499,7 +495,7 @@ static int cli_loadwdb(FILE *fs, struct cl_engine **engine, unsigned int options
}
}
- if((ret = load_regex_matcher((*engine)->whitelist_matcher, fs, options, 1, dbio))) {
+ if((ret = load_regex_matcher((*engine)->whitelist_matcher, fs, options, 1, gzs, gzrsize))) {
phishing_done(*engine);
cl_free(*engine);
return ret;
@@ -508,7 +504,7 @@ static int cli_loadwdb(FILE *fs, struct cl_engine **engine, unsigned int options
return CL_SUCCESS;
}
-static int cli_loadpdb(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio)
+static int cli_loadpdb(FILE *fs, struct cl_engine **engine, unsigned int options, gzFile *gzs, unsigned int gzrsize)
{
int ret = 0;
@@ -529,7 +525,7 @@ static int cli_loadpdb(FILE *fs, struct cl_engine **engine, unsigned int options
}
}
- if((ret = load_regex_matcher((*engine)->domainlist_matcher, fs, options, 0, dbio))) {
+ if((ret = load_regex_matcher((*engine)->domainlist_matcher, fs, options, 0, gzs, gzrsize))) {
phishing_done(*engine);
cl_free(*engine);
return ret;
@@ -539,7 +535,7 @@ static int cli_loadpdb(FILE *fs, struct cl_engine **engine, unsigned int options
}
#define NDB_TOKENS 6
-static int cli_loadndb(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned short sdb, unsigned int options, struct cli_dbio *dbio, const char *dbname)
+static int cli_loadndb(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned short sdb, unsigned int options, gzFile *gzs, unsigned int gzrsize, const char *dbname)
{
const char *tokens[NDB_TOKENS];
char buffer[FILEBUFF];
@@ -560,7 +556,7 @@ static int cli_loadndb(FILE *fs, struct cl_engine **engine, unsigned int *signo,
return ret;
}
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
if(!strncmp(buffer, "Exploit.JPEG.Comment", 20)) /* temporary */
@@ -663,7 +659,7 @@ static int cli_loadndb(FILE *fs, struct cl_engine **engine, unsigned int *signo,
}
#define FTM_TOKENS 8
-static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options, unsigned int internal, struct cli_dbio *dbio)
+static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options, unsigned int internal, gzFile *gzs, unsigned int gzrsize)
{
const char *tokens[FTM_TOKENS], *pt;
char buffer[FILEBUFF];
@@ -690,7 +686,7 @@ static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options
strncpy(buffer, ftypes_int[line], sizeof(buffer));
buffer[sizeof(buffer)-1]='\0';
} else {
- if(!cli_dbgets(buffer, FILEBUFF, fs, dbio))
+ if(!cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize))
break;
cli_chomp(buffer);
}
@@ -781,7 +777,7 @@ static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options
return CL_SUCCESS;
}
-static int cli_loadign(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio)
+static int cli_loadign(FILE *fs, struct cl_engine **engine, unsigned int options, gzFile *gzs, unsigned int gzrsize)
{
char buffer[FILEBUFF], *pt;
unsigned int line = 0;
@@ -803,7 +799,7 @@ static int cli_loadign(FILE *fs, struct cl_engine **engine, unsigned int options
}
}
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
cli_chomp(buffer);
@@ -917,7 +913,7 @@ static int cli_md5db_init(struct cl_engine **engine, unsigned int mode)
else \
db = (*engine)->md5_fp;
-static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned int mode, unsigned int options, struct cli_dbio *dbio, const char *dbname)
+static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo, unsigned int mode, unsigned int options, gzFile *gzs, unsigned int gzrsize, const char *dbname)
{
char buffer[FILEBUFF], *pt;
int ret = CL_SUCCESS;
@@ -936,7 +932,7 @@ static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo,
md5_field = 1;
}
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
cli_chomp(buffer);
@@ -1031,7 +1027,7 @@ static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo,
return CL_SUCCESS;
}
-static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo, int type, unsigned int options, struct cli_dbio *dbio, const char *dbname)
+static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo, int type, unsigned int options, gzFile *gzs, unsigned int gzrsize, const char *dbname)
{
char buffer[FILEBUFF], *pt;
unsigned int line = 0, sigs = 0;
@@ -1044,7 +1040,7 @@ static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo,
return ret;
}
- while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fs, gzs, &gzrsize)) {
line++;
if(buffer[0] == '#')
continue;
@@ -1212,7 +1208,7 @@ static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo,
static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo, unsigned int options);
-int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options, struct cli_dbio *dbio)
+int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options, gzFile *gzs, unsigned int gzrsize)
{
FILE *fs = NULL;
int ret = CL_SUCCESS;
@@ -1220,7 +1216,7 @@ int cli_load(const char *filename, struct cl_engine **engine, unsigned int *sign
const char *dbname;
- if(!dbio && (fs = fopen(filename, "rb")) == NULL) {
+ if(!gzs && (fs = fopen(filename, "rb")) == NULL) {
cli_errmsg("cli_load(): Can't open file %s\n", filename);
return CL_EOPEN;
}
@@ -1237,7 +1233,7 @@ int cli_load(const char *filename, struct cl_engine **engine, unsigned int *sign
dbname = filename;
if(cli_strbcasestr(dbname, ".db")) {
- ret = cli_loaddb(fs, engine, signo, options, dbio, dbname);
+ ret = cli_loaddb(fs, engine, signo, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".cvd")) {
int warn = 0;
@@ -1256,66 +1252,66 @@ int cli_load(const char *filename, struct cl_engine **engine, unsigned int *sign
ret = cli_cvdload(fs, engine, signo, warn, options | CL_DB_CVDNOTMP, 1);
} else if(cli_strbcasestr(dbname, ".hdb")) {
- ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, dbio, dbname);
+ ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".hdu")) {
if(options & CL_DB_PUA)
- ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, dbio, dbname);
+ ret = cli_loadmd5(fs, engine, signo, MD5_HDB, options, gzs, gzrsize, dbname);
else
skipped = 1;
} else if(cli_strbcasestr(dbname, ".fp")) {
- ret = cli_loadmd5(fs, engine, signo, MD5_FP, options, dbio, dbname);
+ ret = cli_loadmd5(fs, engine, signo, MD5_FP, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".mdb")) {
- ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, dbio, dbname);
+ ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".mdu")) {
if(options & CL_DB_PUA)
- ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, dbio, dbname);
+ ret = cli_loadmd5(fs, engine, signo, MD5_MDB, options, gzs, gzrsize, dbname);
else
skipped = 1;
} else if(cli_strbcasestr(dbname, ".ndb")) {
- ret = cli_loadndb(fs, engine, signo, 0, options, dbio, dbname);
+ ret = cli_loadndb(fs, engine, signo, 0, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".ndu")) {
if(!(options & CL_DB_PUA))
skipped = 1;
else
- ret = cli_loadndb(fs, engine, signo, 0, options, dbio, dbname);
+ ret = cli_loadndb(fs, engine, signo, 0, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".sdb")) {
- ret = cli_loadndb(fs, engine, signo, 1, options, dbio, dbname);
+ ret = cli_loadndb(fs, engine, signo, 1, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".zmd")) {
- ret = cli_loadmd(fs, engine, signo, 1, options, dbio, dbname);
+ ret = cli_loadmd(fs, engine, signo, 1, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".rmd")) {
- ret = cli_loadmd(fs, engine, signo, 2, options, dbio, dbname);
+ ret = cli_loadmd(fs, engine, signo, 2, options, gzs, gzrsize, dbname);
} else if(cli_strbcasestr(dbname, ".cfg")) {
- ret = cli_dconf_load(fs, engine, options, dbio);
+ ret = cli_dconf_load(fs, engine, options, gzs, gzrsize);
} else if(cli_strbcasestr(dbname, ".wdb")) {
if(options & CL_DB_PHISHING_URLS) {
- ret = cli_loadwdb(fs, engine, options, dbio);
+ ret = cli_loadwdb(fs, engine, options, gzs, gzrsize);
} else
skipped = 1;
} else if(cli_strbcasestr(dbname, ".pdb")) {
if(options & CL_DB_PHISHING_URLS) {
- ret = cli_loadpdb(fs, engine, options, dbio);
+ ret = cli_loadpdb(fs, engine, options, gzs, gzrsize);
} else
skipped = 1;
} else if(cli_strbcasestr(dbname, ".ftm")) {
- ret = cli_loadftm(fs, engine, options, 0, dbio);
+ ret = cli_loadftm(fs, engine, options, 0, gzs, gzrsize);
} else if(cli_strbcasestr(dbname, ".ign")) {
- ret = cli_loadign(fs, engine, options, dbio);
+ ret = cli_loadign(fs, engine, options, gzs, gzrsize);
} else {
cli_dbgmsg("cli_load: unknown extension - assuming old database format\n");
- ret = cli_loaddb(fs, engine, signo, options, dbio, dbname);
+ ret = cli_loaddb(fs, engine, signo, options, gzs, gzrsize, dbname);
}
if(ret) {
@@ -1334,7 +1330,7 @@ int cli_load(const char *filename, struct cl_engine **engine, unsigned int *sign
}
int cl_loaddb(const char *filename, struct cl_engine **engine, unsigned int *signo) {
- return cli_load(filename, engine, signo, CL_DB_STDOPT, NULL);
+ return cli_load(filename, engine, signo, CL_DB_STDOPT, NULL, 0);
}
static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigned int *signo, unsigned int options)
@@ -1358,7 +1354,7 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigne
/* try to load local.ign and daily.cvd/daily.ign first */
sprintf(dbfile, "%s/local.ign", dirname);
- if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) {
+ if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL, 0))) {
free(dbfile);
return ret;
}
@@ -1366,20 +1362,20 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigne
sprintf(dbfile, "%s/daily.cld", dirname);
if(access(dbfile, R_OK))
sprintf(dbfile, "%s/daily.cvd", dirname);
- if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) {
+ if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL, 0))) {
free(dbfile);
return ret;
}
sprintf(dbfile, "%s/daily.ign", dirname);
- if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) {
+ if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL, 0))) {
free(dbfile);
return ret;
}
/* check for and load daily.cfg */
sprintf(dbfile, "%s/daily.cfg", dirname);
- if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL))) {
+ if(!access(dbfile, R_OK) && (ret = cli_load(dbfile, engine, signo, options, NULL, 0))) {
free(dbfile);
return ret;
}
@@ -1411,7 +1407,7 @@ static int cli_loaddbdir(const char *dirname, struct cl_engine **engine, unsigne
return CL_EMEM;
}
sprintf(dbfile, "%s/%s", dirname, dent->d_name);
- ret = cli_load(dbfile, engine, signo, options, NULL);
+ ret = cli_load(dbfile, engine, signo, options, NULL, 0);
if(ret) {
cli_dbgmsg("cli_loaddbdir(): error loading database %s\n", dbfile);
@@ -1455,7 +1451,7 @@ int cl_load(const char *path, struct cl_engine **engine, unsigned int *signo, un
switch(sb.st_mode & S_IFMT) {
case S_IFREG:
- ret = cli_load(path, engine, signo, options, NULL);
+ ret = cli_load(path, engine, signo, options, NULL, 0);
break;
case S_IFDIR:
@@ -1787,7 +1783,7 @@ int cl_build(struct cl_engine *engine)
return CL_ENULLARG;
if(!engine->ftypes)
- if((ret = cli_loadftm(NULL, &engine, 0, 1, NULL)))
+ if((ret = cli_loadftm(NULL, &engine, 0, 1, NULL, 0)))
return ret;
for(i = 0; i < CLI_MTARGETS; i++) {
diff --git a/libclamav/readdb.h b/libclamav/readdb.h
index a67e7ef..2c67502 100644
--- a/libclamav/readdb.h
+++ b/libclamav/readdb.h
@@ -21,11 +21,12 @@
#ifndef __READDB_H
#define __READDB_H
+#include <zlib.h>
+
#include "clamav.h"
#include "matcher.h"
#include "str.h"
#include "cltypes.h"
-#include "cvd.h"
#define CLI_DBEXT(ext) \
( \
@@ -51,12 +52,13 @@
cli_strbcasestr(ext, ".cld") \
)
+
int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hexsig, uint16_t rtype, uint16_t type, const char *offset, uint8_t target);
int cli_initengine(struct cl_engine **engine, unsigned int options);
-int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options, struct cli_dbio *dbio);
+int cli_load(const char *filename, struct cl_engine **engine, unsigned int *signo, unsigned int options, gzFile *gzs, unsigned int gzrsize);
-char *cli_dbgets(char *buff, unsigned int size, FILE *fs, struct cli_dbio *dbio);
+char *cli_dbgets(char *buff, unsigned int size, FILE *fs, gzFile *gzs, unsigned int *gzrsize);
#endif
diff --git a/libclamav/regex_list.c b/libclamav/regex_list.c
index d33bc7b..fd3ac3a 100644
--- a/libclamav/regex_list.c
+++ b/libclamav/regex_list.c
@@ -522,7 +522,7 @@ static int functionality_level_check(char* line)
/* Load patterns/regexes from file */
-int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,struct cli_dbio *dbio)
+int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,gzFile *gzs,unsigned int gzrsize)
{
int rc,line=0;
char buffer[FILEBUFF];
@@ -535,7 +535,7 @@ int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int optio
cli_warnmsg("Regex list has already been loaded, ignoring further requests for load\n");
return CL_SUCCESS;
}*/
- if(!fd && !dbio) {
+ if(!fd && !gzs) {
cli_errmsg("Unable to load regex list (null file)\n");
return CL_EIO;
}
@@ -570,7 +570,7 @@ int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int optio
* If a line in the file doesn't conform to this format, loading fails
*
*/
- while(cli_dbgets(buffer, FILEBUFF, fd, dbio)) {
+ while(cli_dbgets(buffer, FILEBUFF, fd, gzs, &gzrsize)) {
char* pattern;
char* flags;
cli_chomp(buffer);
diff --git a/libclamav/regex_list.h b/libclamav/regex_list.h
index 90a2ef1..3d82acc 100644
--- a/libclamav/regex_list.h
+++ b/libclamav/regex_list.h
@@ -35,8 +35,6 @@
#endif
#include "phishcheck.h"
-#include "readdb.h"
-#include "matcher.h"
#include <zlib.h> /* for gzFile */
struct node_stack {
struct tree_node** data;
@@ -58,7 +56,7 @@ struct regex_matcher {
int regex_list_match(struct regex_matcher* matcher, char* real_url,const char* display_url,const struct pre_fixup_info* pre_fixup, int hostOnly,const char** info,int is_whitelist);
int init_regex_list(struct regex_matcher* matcher);
-int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,struct cli_dbio *dbio);
+int load_regex_matcher(struct regex_matcher* matcher,FILE* fd,unsigned int options,int is_whitelist,gzFile *gzs,unsigned int gzrsize);
void regex_list_cleanup(struct regex_matcher* matcher);
void regex_list_done(struct regex_matcher* matcher);
int is_regex_ok(struct regex_matcher* matcher);
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list