summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2021-01-13 20:20:35 +0200
committerMavridis Philippe <mavridisf@gmail.com>2021-01-13 20:20:35 +0200
commit2d1fd0b27546b529c1130573d6eba8f62d03bdc1 (patch)
treea25426398caf5c97c1566b1dd26299703ac779a0
parent522bc92a7e95eab9e940c0c3a869aac2939f0793 (diff)
downloadklamav-2d1fd0b27546b529c1130573d6eba8f62d03bdc1.tar.gz
klamav-2d1fd0b27546b529c1130573d6eba8f62d03bdc1.zip
Klammail: fixed LibClamAV function calls
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rwxr-xr-xsrc/klammail/clamdmail.c71
1 files changed, 15 insertions, 56 deletions
diff --git a/src/klammail/clamdmail.c b/src/klammail/clamdmail.c
index 19f985e..101e9b7 100755
--- a/src/klammail/clamdmail.c
+++ b/src/klammail/clamdmail.c
@@ -41,6 +41,8 @@
#include "../version.h"
#include "../../config.h"
+#include "output.h"
+
#define BUFFSIZE 1024
@@ -71,7 +73,7 @@ void startclamd(struct optstruct *opt);
struct s_info claminfo;
short printinfected = 0;
-short int mprintf_stdout;
+/* short int mprintf_stdout; */
int clamdscan(struct optstruct *opt)
{
@@ -97,9 +99,6 @@ int clamdscan(struct optstruct *opt)
long double mb;
const char *virname;
struct cl_engine *engine = NULL;
-#ifndef SUPPORT_CLAMAV_V095
- struct cl_limits limits;
-#endif
struct stat sb;
if(optc(opt, 'V')) {
@@ -158,12 +157,8 @@ int clamdscan(struct optstruct *opt)
}
if(fsync(fd) == -1) {
- close(fd);
-#ifdef SUPPORT_CLAMAV_V095
- return CL_ETMPFILE;
-#else
- return CL_EIO;
-#endif
+ close(fd);
+ return CL_ETMPFILE;
}
close(fd);
@@ -182,30 +177,22 @@ int clamdscan(struct optstruct *opt)
if((ret == 2)) {
/* Clamd isn't running, start it so it is available next time. */
startclamd(opt);
-#ifdef SUPPORT_CLAMAV_V095
+
if((engine = cl_engine_new()) == NULL) {
printf("Database initialization error: %s\n", cl_strerror(ret));;
cl_engine_free(engine);
close(fd);
exit(2);
}
-#endif
+
if(optc(opt, 'd')) {
-#ifdef SUPPORT_CLAMAV_V095
if((ret = cl_load(getargc(opt, 'd'), engine, &no, CL_DB_STDOPT))) {
-#else
- if((ret = cl_load(getargc(opt, 'd'), &engine, &no, CL_DB_STDOPT))) {
-#endif
printf("cl_load: %s\n", cl_strerror(ret));
close(fd);
return 50;
}
}else{
-#ifdef SUPPORT_CLAMAV_V095
if((ret = cl_load(cl_retdbdir(), engine, &no, CL_DB_STDOPT))) {
-#else
- if((ret = cl_loaddbdir(cl_retdbdir(), &engine, &no, CL_DB_STDOPT))) {
-#endif
printf("cl_loaddbdir: %s\n", cl_strerror(ret));
close(fd);
exit(2);
@@ -213,42 +200,22 @@ int clamdscan(struct optstruct *opt)
}
/* build engine */
-#ifdef SUPPORT_CLAMAV_V095
if((ret = cl_engine_compile(engine))) {
-#else
- if((ret = cl_build(engine))) {
-#endif
printf("Database initialization error: %s\n", cl_strerror(ret));;
-#ifdef SUPPORT_CLAMAV_V095
cl_engine_free(engine);
-#else
- cl_free(engine);
-#endif
close(fd);
exit(2);
}
-#ifndef SUPPORT_CLAMAV_V095
- /* set up archive limits */
- memset(&limits, 0, sizeof(struct cl_limits));
- limits.maxfiles = 1000; /* max files */
- limits.maxfilesize = 10 * 1048576; /* maximum size of archived/compressed
- * file (files exceeding this limit
- * will be ignored)
- */
- /*limits.maxreclevel = 5;*/ /* maximum recursion level for archives */
- /*limits.maxmailrec = 64;*/ /* maximum recursion level for mail files */
- /*limits.maxratio = 200;*/ /* maximum compression ratio */
- limits.archivememlim = 1;
-#endif
-#ifdef SUPPORT_CLAMAV_V095
- ret = cl_scandesc(fd, &virname, &size, engine,
- CL_SCAN_STDOPT | CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_HTML);
+ ret = cl_scandesc(fd, tmpnm, &virname, &size, engine,
+ CL_SCAN_GENERAL_ALLMATCHES | CL_SCAN_GENERAL_HEURISTICS |
+ CL_SCAN_PARSE_ARCHIVE | CL_SCAN_PARSE_MAIL | CL_SCAN_PARSE_OLE2 |
+ CL_SCAN_PARSE_HTML | CL_SCAN_PARSE_PDF );
printf("scandesc returned: %i\n", cl_strerror(ret));;
-#else
- ret = cl_scandesc(fd, &virname, &size, engine, &limits,
- CL_SCAN_STDOPT | CL_ARCHIVE | CL_MAIL | CL_OLE2 | CL_SCAN_HTML);
-#endif
+ if( ret == CL_VIRUS )
+ printf("virus found\n");
+ else
+ printf("file clean\n");
}
/* scan descriptor (with archive and mail scanning enabled) */
@@ -258,11 +225,7 @@ int clamdscan(struct optstruct *opt)
spoolstdin(tmpnm, fd, ret, &virname, &bndrystore, opt);
if((ret == 2))
-#ifdef SUPPORT_CLAMAV_V095
cl_engine_free(engine);
-#else
- cl_free(engine);
-#endif
unlink(tmpnm);
@@ -582,11 +545,7 @@ void startclamd(struct optstruct *opt)
if ((strstr(cl_retver(), "0.8")) || (strstr(cl_retver(), "0.7")))
fprintf(tmp,"FixStaleSocket\n");
else
-#ifdef SUPPORT_CLAMAV_V095
fprintf(tmp,"FixStaleSocket yes\n");
-#else
- fprintf(tmp,"FixStaleSocket TRUE\n");
-#endif
fflush(tmp);