add 7z SFX support - bb#3063

remotes/push_mirror/fmapify
aCaB 14 years ago
parent 5bc82d58b9
commit 9a47aa20e6
  1. 4
      ChangeLog
  2. 6
      libclamav/7z_iface.c
  3. 2
      libclamav/7z_iface.h
  4. 1
      libclamav/filetypes.c
  5. 1
      libclamav/filetypes.h
  6. 1
      libclamav/filetypes_int.h
  7. 11
      libclamav/scanners.c

@ -1,3 +1,7 @@
Tue Nov 1 12:26:46 CET 2011 (acab)
-----------------------------------
* libclamav: Add 7z SFX support (b#3063)
Thu Jun 9 08:22:31 CEST 2011 (acab)
------------------------------------
* libclamav/mew.c: harden boundary check on e8/e9 fixup

@ -71,13 +71,14 @@ static SRes FileInStream_fmap_Seek(void *pp, Int64 *pos, ESzSeek origin) {
}
#define UTFBUFSZ 256
int cli_7unz (cli_ctx *ctx) {
int cli_7unz (cli_ctx *ctx, size_t offset) {
CFileInStream archiveStream;
CLookToRead lookStream;
CSzArEx db;
SRes res;
UInt16 utf16buf[UTFBUFSZ], *utf16name = utf16buf;
int namelen = UTFBUFSZ, found = CL_CLEAN;
Int64 begin_of_archive = offset;
/* Replacement for
FileInStream_CreateVTable(&archiveStream); */
@ -88,6 +89,9 @@ int cli_7unz (cli_ctx *ctx) {
LookToRead_CreateVTable(&lookStream, False);
if(archiveStream.s.Seek(&archiveStream.s, &begin_of_archive, SZ_SEEK_SET) != 0)
return CL_CLEAN;
lookStream.realStream = &archiveStream.s;
LookToRead_Init(&lookStream);

@ -27,6 +27,6 @@
#include "others.h"
int cli_7unz (cli_ctx *);
int cli_7unz (cli_ctx *, size_t);
#endif

@ -96,6 +96,7 @@ static const struct ftmap_s {
{ "CL_TYPE_AUTOIT", CL_TYPE_AUTOIT },
{ "CL_TYPE_ISHIELD_MSI", CL_TYPE_ISHIELD_MSI },
{ "CL_TYPE_7Z", CL_TYPE_7Z },
{ "CL_TYPE_7ZSFX", CL_TYPE_7ZSFX },
{ "CL_TYPE_SWF", CL_TYPE_SWF },
{ NULL, CL_TYPE_IGNORED }
};

@ -80,6 +80,7 @@ typedef enum {
CL_TYPE_SFX, /* foo SFX marker */
CL_TYPE_ZIPSFX, /* on the fly */
CL_TYPE_RARSFX, /* on the fly */
CL_TYPE_7ZSFX,
CL_TYPE_CABSFX,
CL_TYPE_ARJSFX,
CL_TYPE_NULSFT, /* on the fly */

@ -155,6 +155,7 @@ static const char *ftypes_int[] = {
"0:0:435753:SWF (compressed):CL_TYPE_ANY:CL_TYPE_SWF:62",
"0:0:465753:SWF (uncompressed):CL_TYPE_ANY:CL_TYPE_SWF:62",
"0:0:ffd9ffd8:JPEG (bad header):CL_TYPE_ANY:CL_TYPE_GRAPHICS:62",
"1:*:377abcaf271c:7zip-SFX:CL_TYPE_ANY:CL_TYPE_7ZSFX",
NULL
};

@ -1902,6 +1902,15 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
}
break;
case CL_TYPE_7ZSFX:
if(type != CL_TYPE_7Z && SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_7Z)) {
ctx->container_type = CL_TYPE_7Z;
ctx->container_size = map->len - fpt->offset; /* not precise */
cli_dbgmsg("7Zip-SFX signature found at %u\n", (unsigned int) fpt->offset);
nret = cli_7unz(ctx, fpt->offset);
}
break;
case CL_TYPE_NULSFT:
if(SCAN_ARCHIVE && type == CL_TYPE_MSEXE && (DCONF_ARCH & ARCH_CONF_NSIS) && fpt->offset > 4) {
ctx->container_type = CL_TYPE_NULSFT;
@ -2307,7 +2316,7 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
case CL_TYPE_7Z:
ctx->container_type = CL_TYPE_7Z;
if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_7Z))
ret = cli_7unz(ctx);
ret = cli_7unz(ctx, 0);
break;
case CL_TYPE_POSIX_TAR:

Loading…
Cancel
Save