Код: Выделить всё
# cat scanners.c.rej
***************
*** 42,53 ****
#include <mspack.h>
#ifdef CL_THREAD_SAFE
# include <pthread.h>
pthread_mutex_t cli_scanrar_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
int cli_scanrar_inuse = 0;
-
extern short cli_leavetemps_flag;
extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME */
--- 42,54 ----
#include <mspack.h>
+ #ifndef UNRAR3
#ifdef CL_THREAD_SAFE
# include <pthread.h>
pthread_mutex_t cli_scanrar_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
int cli_scanrar_inuse = 0;
+ #endif
extern short cli_leavetemps_flag;
extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME */
***************
*** 108,113 ****
static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec);
#ifdef CL_THREAD_SAFE
static void cli_unlock_mutex(void *mtx)
{
--- 109,115 ----
static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec);
+ #ifndef UNRAR3
#ifdef CL_THREAD_SAFE
static void cli_unlock_mutex(void *mtx)
{
***************
*** 286,291 ****
return ret;
}
#ifdef HAVE_ZLIB_H
static int cli_scanzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec)
--- 288,294 ----
return ret;
}
+ #endif
#ifdef HAVE_ZLIB_H
static int cli_scanzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec)
***************
*** 1076,1081 ****
return ret;
}
static int cli_scanmschm(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec)
{
char *tempname;
--- 1079,1121 ----
return ret;
}
+ #ifdef UNRAR3
+ static int cli_scanrar3(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec)
+ {
+ const char *tmpdir;
+ char *dir;
+ int ret = CL_CLEAN;
+
+
+ cli_dbgmsg("in cli_scanrar3()\n");
+
+ if((tmpdir = getenv("TMPDIR")) == NULL)
+ #ifdef P_tmpdir
+ tmpdir = P_tmpdir;
+ #else
+ tmpdir = "/tmp";
+ #endif
+
+ /* generate temporary directory */
+ dir = cli_gentemp(tmpdir);
+ if(mkdir(dir, 0700)) {
+ cli_errmsg("Rar3: Can't create temporary directory %s\n", dir);
+ return CL_ETMPDIR;
+ }
+
+ if((ret = cli_unrar3(dir, desc)))
+ cli_dbgmsg("Rar3: %s\n", cl_strerror(ret));
+ else
+ ret = cli_scandir(dir, virname, scanned, root, limits, options, arec, mrec);
+
+ if(!cli_leavetemps_flag)
+ cli_rmdirs(dir);
+
+ free(dir);
+ return ret;
+ }
+ #endif
+
static int cli_scanmschm(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec)
{
char *tempname;
***************
*** 1210,1217 ****
switch(type) {
case CL_TYPE_RAR:
if(!DISABLE_RAR && SCAN_ARCHIVE && !cli_scanrar_inuse)
ret = cli_scanrar(desc, virname, scanned, root, limits, options, arec, mrec);
break;
case CL_TYPE_ZIP:
--- 1250,1262 ----
switch(type) {
case CL_TYPE_RAR:
+ #ifdef UNRAR3
+ if(!DISABLE_RAR && SCAN_ARCHIVE)
+ ret = cli_scanrar3(desc, virname, scanned, root, limits, options, arec, mrec);
+ #else
if(!DISABLE_RAR && SCAN_ARCHIVE && !cli_scanrar_inuse)
ret = cli_scanrar(desc, virname, scanned, root, limits, options, arec, mrec);
+ #endif
break;
case CL_TYPE_ZIP:
***************
*** 1328,1335 ****
* in raw mode. Now we will try to unpack them
*/
case CL_TYPE_MSEXE:
if(SCAN_PE)
ret = cli_scanpe(desc, virname, scanned, root, limits, options, arec, mrec);
break;
default:
--- 1373,1389 ----
* in raw mode. Now we will try to unpack them
*/
case CL_TYPE_MSEXE:
+ #ifdef UNRAR3
+ if(!DISABLE_RAR && SCAN_ARCHIVE)
+ ret = cli_scanrar3(desc, virname, scanned, root, limits, options, arec, mrec);
+ if(SCAN_PE && ret != CL_VIRUS)
+ #else
if(SCAN_PE)
+ #endif
+ {
+ lseek(desc, 0, SEEK_SET);
ret = cli_scanpe(desc, virname, scanned, root, limits, options, arec, mrec);
+ }
break;
default: