diff --git a/p3scan-3.0_rc1/src/p3scan.c b/p3scan-3.0_rc1/src/p3scan.c index 6b85b79..bd7e149 100644 --- a/p3scan-3.0_rc1/src/p3scan.c +++ b/p3scan-3.0_rc1/src/p3scan.c @@ -182,7 +182,7 @@ static struct cl_stat *dbstat = NULL; //struct cl_stat dbstat; const struct cfgstruct *copt; struct cl_engine *engine = NULL; -struct cl_limits limits; +/* struct cl_limits limits; */ struct cl_cvd *daily; const char *dbdir; unsigned int sigs = 0; @@ -281,7 +281,7 @@ void do_sigterm_main(int signr){ } if((ret=unlink(config->pidfile)!=0)) do_log(LOG_NOTICE, "ERR: Unable to remove %s", config->pidfile); #if HAVE_CLAMAV - if (engine) cl_free(engine); + if (engine) cl_engine_free(engine); #endif do_log(LOG_NOTICE, PROGRAM " terminates now"); exit(EXIT_SUCCESS); @@ -536,9 +536,15 @@ int init_clamav(void){ mvold=0; if (config->clamav){ if(engine){ - cl_free(engine); + cl_engine_free(engine); engine = NULL; } + if (cl_init(CL_SCAN_STDOPT) != CL_SUCCESS) { + do_log(LOG_EMERG, "ERR: cant init libclamav"); + return SCANNER_RET_ERR; + } else { + engine = cl_engine_new(); + } dbdir=cl_retdbdir(); /* // Check for updated info first, if we find it, then check for old data and mv it so it is @@ -566,27 +572,27 @@ int init_clamav(void){ if(dbstat == NULL){ dbstat = (struct cl_stat *) malloc(sizeof(struct cl_stat)); if(!dbstat) { - cl_free(engine); + cl_engine_free(engine); do_log(LOG_EMERG, "ClamAV can't allocate memory for dbstat ERR: %s",cl_strerror(ret)); return SCANNER_RET_ERR; } } else { if((ret = cl_statfree(dbstat))){ - if (engine) cl_free(engine); + if (engine) cl_engine_free(engine); do_log(LOG_EMERG, "ClamAV Database statfree ERR: %s",cl_strerror(ret)); return SCANNER_RET_ERR; } } //if((ret = cl_loaddbdir(dbdir, &engine, &sigs))) { - if((ret = cl_load(dbdir, &engine, &sigs, CL_DB_STDOPT))) { - if (engine) cl_free(engine); + if((ret = cl_load(dbdir, engine, &sigs, CL_DB_STDOPT))) { + if (engine) cl_engine_free(engine); if (dbstat) cl_statfree(dbstat); do_log(LOG_EMERG, "ERR: %s",cl_strerror(ret)); return SCANNER_RET_ERR; } // build engine - if((ret = cl_build(engine))){ - if (engine) cl_free(engine); + if((ret = cl_engine_compile(engine))){ + if (engine) cl_engine_free(engine); if (dbstat) cl_statfree(dbstat); // Emergency: init_clamav. could not init. do_log(LOG_EMERG, "ClamAV Database build ERR: %s",cl_strerror(ret)); @@ -595,15 +601,19 @@ int init_clamav(void){ memset(dbstat, 0, sizeof(struct cl_stat)); cl_statinidir(dbdir, dbstat); // set up archive limits (ClamAV Defaults) - memset(&limits, 0, sizeof(struct cl_limits)); - limits.maxfilesize = 25 * 1048576; // compressed files will only be decompressed and scanned up to this size - limits.maxreclevel = 16; // maximum recursion level for archives - limits.maxfiles = 1000; // maximum number of files to be scanned within a single archive + /* memset(&limits, 0, sizeof(struct cl_limits)); */ + cl_engine_set_num(engine,CL_ENGINE_MAX_FILESIZE, 25 * 1048576); + /* limits.maxfilesize = 25 * 1048576; // compressed files will only be decompressed and scanned up to this size */ + cl_engine_set_num(engine,CL_ENGINE_MAX_RECURSION, 16); + /* limits.maxreclevel = 16; // maximum recursion level for archives */ + cl_engine_set_num(engine,CL_ENGINE_MAX_FILES, 1000); + /* limits.maxfiles = 1000; // maximum number of files to be scanned within a single archive */ #ifdef HAVE_MAXSCANSIZE - limits.maxscansize = 100 * 1048576; // during the scanning of archives this size will never be exceeded + cl_engine_set_num(engine,CL_ENGINE_MAX_SCANSIZE, 100 * 1048576); + /* limits.maxscansize = 100 * 1048576; // during the scanning of archives this size will never be exceeded */ #else - limits.maxmailrec = 64; // maximum recursion level for mail files - limits.maxratio = 200; // maximum compression ratio + /* limits.maxmailrec = 64; // maximum recursion level for mail files */ + /* limits.maxratio = 200; // maximum compression ratio */ #endif } if (reload){ @@ -761,7 +771,7 @@ int scan_directory(struct proxycontext *p){ return SCANNER_RET_CRIT; } /* scan descriptor */ - if ((viret = cl_scandesc(fdc, &virnamec, &blocks, engine, &limits, CL_SCAN_STDOPT)) == CL_VIRUS){ + if ((viret = cl_scandesc(fdc, &virnamec, &blocks, engine, CL_SCAN_STDOPT)) == CL_VIRUS){ p->virinfo=strdup(virnamec); viret=SCANNER_RET_VIRUS; } else if (viret != CL_CLEAN) do_log(LOG_CRIT,"ERR: %s", cl_strerror(ret)); @@ -1170,7 +1180,7 @@ int scan_mailfile(struct proxycontext *p){ return SCANNER_RET_CRIT; } /* scan descriptor */ - if ((viret = cl_scandesc(fdc, &clamvirname, &blocks, engine, &limits, CL_SCAN_STDOPT)) == CL_VIRUS){ + if ((viret = cl_scandesc(fdc, &clamvirname, &blocks, engine, CL_SCAN_STDOPT)) == CL_VIRUS){ p->virinfo=strdup(clamvirname); viret=SCANNER_RET_VIRUS; } else if (viret != CL_CLEAN) do_log(LOG_CRIT,"ERR: %s", cl_strerror(ret));