diff options
author | Michael Mair-Keimberger <m.mairkeimberger@gmail.com> | 2018-05-27 13:57:09 +0200 |
---|---|---|
committer | Aaron Bauman <bman@gentoo.org> | 2018-05-27 12:09:21 -0400 |
commit | b706131c0f3184e53e71a7f787ac28385d12526c (patch) | |
tree | 16c9847094b817c22b41f2314ee7682a8fcc24d6 /app-antivirus/clamav | |
parent | dev-db/sqlite: remove unused patches (diff) | |
download | gentoo-b706131c0f3184e53e71a7f787ac28385d12526c.tar.gz gentoo-b706131c0f3184e53e71a7f787ac28385d12526c.tar.bz2 gentoo-b706131c0f3184e53e71a7f787ac28385d12526c.zip |
app-antivirus/clamav: remove unused patches
Closes: https://github.com/gentoo/gentoo/pull/8607
Diffstat (limited to 'app-antivirus/clamav')
7 files changed, 0 insertions, 509 deletions
diff --git a/app-antivirus/clamav/files/clamav-0.99-zlib.patch b/app-antivirus/clamav/files/clamav-0.99-zlib.patch deleted file mode 100644 index 8d1f4e615379..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99-zlib.patch +++ /dev/null @@ -1,22 +0,0 @@ -commit f0bcd186190fe6e67b3f0eaaceb7a99aa6a98865 -Author: Steven Morgan <stevmorg@cisco.com> -Date: Thu Jan 5 12:30:35 2017 -0500 - - bb111711 - fix zlib version check - patch by Daniel J. Luke. - -diff --git a/m4/reorganization/libs/libz.m4 b/m4/reorganization/libs/libz.m4 -index b5c7414..f7b67ca 100644 ---- a/m4/reorganization/libs/libz.m4 -+++ b/m4/reorganization/libs/libz.m4 -@@ -29,9 +29,9 @@ then - AC_MSG_ERROR([Please install zlib and zlib-devel packages]) - else - -- vuln=`grep "ZLIB_VERSION \"1.2.0" $ZLIB_HOME/include/zlib.h` -+ vuln=`grep "ZLIB_VERSION \"1.2.0\"" $ZLIB_HOME/include/zlib.h` - if test -z "$vuln"; then -- vuln=`grep "ZLIB_VERSION \"1.2.1" $ZLIB_HOME/include/zlib.h` -+ vuln=`grep "ZLIB_VERSION \"1.2.1\"" $ZLIB_HOME/include/zlib.h` - fi - - if test -n "$vuln"; then diff --git a/app-antivirus/clamav/files/clamav-0.99.2-bytecode_api.patch b/app-antivirus/clamav/files/clamav-0.99.2-bytecode_api.patch deleted file mode 100644 index d6cd5264ed7d..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.2-bytecode_api.patch +++ /dev/null @@ -1,50 +0,0 @@ -Description: fix compatibility with zlib 1.2.9 and newer -Author: Marc Deslauriers <marc.deslauriers@canonical.com> -Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/clamav/+bug/1692073 - ---- a/libclamav/bytecode_api.c 2017-08-08 15:20:06.651685637 -0400 -+++ b/libclamav/bytecode_api.c 2017-08-15 15:45:14.645714766 -0400 -@@ -811,8 +811,20 @@ int32_t cli_bcapi_inflate_init(struct cl - cli_dbgmsg("bytecode api: inflate_init: invalid buffers!\n"); - return -1; - } -- memset(&stream, 0, sizeof(stream)); -- ret = inflateInit2(&stream, windowBits); -+ -+ b = cli_realloc(ctx->inflates, sizeof(*ctx->inflates)*n); -+ if (!b) { -+ return -1; -+ } -+ ctx->inflates = b; -+ ctx->ninflates = n; -+ b = &b[n-1]; -+ -+ b->from = from; -+ b->to = to; -+ b->needSync = 0; -+ memset(&b->stream, 0, sizeof(stream)); -+ ret = inflateInit2(&b->stream, windowBits); - switch (ret) { - case Z_MEM_ERROR: - cli_dbgmsg("bytecode api: inflateInit2: out of memory!\n"); -@@ -829,20 +841,6 @@ int32_t cli_bcapi_inflate_init(struct cl - cli_dbgmsg("bytecode api: inflateInit2: unknown error %d\n", ret); - return -1; - } -- -- b = cli_realloc(ctx->inflates, sizeof(*ctx->inflates)*n); -- if (!b) { -- inflateEnd(&stream); -- return -1; -- } -- ctx->inflates = b; -- ctx->ninflates = n; -- b = &b[n-1]; -- -- b->from = from; -- b->to = to; -- b->needSync = 0; -- memcpy(&b->stream, &stream, sizeof(stream)); - return n-1; - } - diff --git a/app-antivirus/clamav/files/clamav-0.99.2-gcc-6.patch b/app-antivirus/clamav/files/clamav-0.99.2-gcc-6.patch deleted file mode 100644 index 2031edbd3822..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.2-gcc-6.patch +++ /dev/null @@ -1,84 +0,0 @@ -diff --git a/libclamav/c++/llvm/include/llvm/ADT/StringMap.h b/libclamav/c++/llvm/include/llvm/ADT/StringMap.h -index 59ff6aa..1325394 100644 ---- a/libclamav/c++/llvm/include/llvm/ADT/StringMap.h -+++ b/libclamav/c++/llvm/include/llvm/ADT/StringMap.h -@@ -169,3 +169,3 @@ public: - KeyLength+1; -- unsigned Alignment = alignof<StringMapEntry>(); -+ unsigned Alignment = alignOf<StringMapEntry>(); - -diff --git a/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h b/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h -index 88044c7..86b0f40 100644 ---- a/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h -+++ b/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h -@@ -417,3 +417,3 @@ namespace llvm { - ileAllocator.Allocate(sizeof(IndexListEntry), -- alignof<IndexListEntry>())); -+ alignOf<IndexListEntry>())); - -diff --git a/libclamav/c++/llvm/include/llvm/Support/AlignOf.h b/libclamav/c++/llvm/include/llvm/Support/AlignOf.h -index 6a7a1a6..979e597 100644 ---- a/libclamav/c++/llvm/include/llvm/Support/AlignOf.h -+++ b/libclamav/c++/llvm/include/llvm/Support/AlignOf.h -@@ -51,8 +51,8 @@ struct AlignOf { - --/// alignof - A templated function that returns the mininum alignment of -+/// alignOf - A templated function that returns the mininum alignment of - /// of a type. This provides no extra functionality beyond the AlignOf - /// class besides some cosmetic cleanliness. Example usage: --/// alignof<int>() returns the alignment of an int. -+/// alignOf<int>() returns the alignment of an int. - template <typename T> --static inline unsigned alignof() { return AlignOf<T>::Alignment; } -+static inline unsigned alignOf() { return AlignOf<T>::Alignment; } - -diff --git a/libclamav/c++/llvm/include/llvm/Support/Allocator.h b/libclamav/c++/llvm/include/llvm/Support/Allocator.h -index 4a7251f..17caf5e 100644 ---- a/libclamav/c++/llvm/include/llvm/Support/Allocator.h -+++ b/libclamav/c++/llvm/include/llvm/Support/Allocator.h -@@ -203,3 +203,3 @@ public: - for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) { -- Ptr = Allocator.AlignPtr(Ptr, alignof<T>()); -+ Ptr = Allocator.AlignPtr(Ptr, alignOf<T>()); - if (Ptr + sizeof(T) <= End) -diff --git a/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp b/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp -index b892d85..dc72346 100644 ---- a/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp -+++ b/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp -@@ -495,3 +495,3 @@ void SCEVUnknown::print(raw_ostream &OS) const { - if (isAlignOf(AllocTy)) { -- OS << "alignof(" << *AllocTy << ")"; -+ OS << "alignOf(" << *AllocTy << ")"; - return; -diff --git a/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp b/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp -index 824021c..757ca50 100644 ---- a/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp -+++ b/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp -@@ -569,3 +569,3 @@ void Emitter<CodeEmitter>::emitMemModRMByte(const MachineInstr &MI, - // Calculate what the SS field value should be... -- static const unsigned SSTable[] = { ~0, 0, 1, ~0, 2, ~0, ~0, ~0, 3 }; -+ static const unsigned SSTable[] = { ~0u, 0u, 1u, ~0u, 2u, ~0u, ~0u, ~0u, 3u }; - unsigned SS = SSTable[Scale.getImm()]; -diff --git a/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp b/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp -index 9564fe0..b2b7986 100644 ---- a/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp -+++ b/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp -@@ -332,3 +332,3 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op, - // Calculate what the SS field value should be... -- static const unsigned SSTable[] = { ~0, 0, 1, ~0, 2, ~0, ~0, ~0, 3 }; -+ static const unsigned SSTable[] = { ~0u, 0u, 1u, ~0u, 2u, ~0u, ~0u, ~0u, 3u }; - unsigned SS = SSTable[Scale.getImm()]; -diff --git a/libclamav/mpool.c b/libclamav/mpool.c -index cd38e15..b5e537d 100644 ---- a/libclamav/mpool.c -+++ b/libclamav/mpool.c -@@ -417,3 +417,3 @@ static size_t from_bits(unsigned int bits) { - --static inline unsigned int alignof(size_t size) -+static inline unsigned int alignOf(size_t size) - { -@@ -609,3 +609,3 @@ static void* allocate_aligned(struct MPMAP *mpm, size_t size, unsigned align, co - void *mpool_malloc(struct MP *mp, size_t size) { -- size_t align = alignof(size); -+ size_t align = alignOf(size); - size_t i, needed = align_increase(size+FRAG_OVERHEAD, align); diff --git a/app-antivirus/clamav/files/clamav-0.99.2-pcre2-compile-erroffset.patch b/app-antivirus/clamav/files/clamav-0.99.2-pcre2-compile-erroffset.patch deleted file mode 100644 index 1ee55171afbb..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.2-pcre2-compile-erroffset.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- clamav-0.99.2/libclamav/regex_pcre.c~ 2017-11-28 14:40:56.484208243 +0100 -+++ clamav-0.99.2/libclamav/regex_pcre.c 2017-11-28 14:41:07.301207800 +0100 -@@ -112,7 +112,8 @@ int cli_pcre_addoptions(struct cli_pcre_ - #if USING_PCRE2 - int cli_pcre_compile(struct cli_pcre_data *pd, long long unsigned match_limit, long long unsigned match_limit_recursion, unsigned int options, int opt_override) - { -- int errornum, erroffset; -+ int errornum; -+ size_t erroffset; - pcre2_general_context *gctx; - pcre2_compile_context *cctx; - diff --git a/app-antivirus/clamav/files/clamav-0.99.2-tinfo.patch b/app-antivirus/clamav/files/clamav-0.99.2-tinfo.patch deleted file mode 100644 index 4593d16836e1..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.2-tinfo.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/m4/reorganization/clamdtop.m4 -+++ b/m4/reorganization/clamdtop.m4 -@@ -4,12 +4,20 @@ - - if test "$enable_clamdtop" != "no"; then - -+PKG_CHECK_MODULES([CURSES],[ncurses], -+ [HAVE_LIBNCURSES=yes; CURSES_INCLUDE="<ncurses.h>"], -+ [HAVE_LIBNCURSES=no], -+) -+ -+if test "X$HAVE_LIBNCURSES" != "Xyes"; then -+ HAVE_LIBNCURSES= - AC_LIB_FIND([ncurses], [ncurses/ncurses.h], - AC_LANG_PROGRAM([#include <ncurses/ncurses.h>], - [initscr(); KEY_RESIZE;]), - [CURSES_CPPFLAGS="$INCNCURSES"; CURSES_LIBS="$LTLIBNCURSES"; - CURSES_INCLUDE="<ncurses/ncurses.h>"], - []) -+fi - - if test "X$HAVE_LIBNCURSES" != "Xyes"; then - HAVE_LIBNCURSES= diff --git a/app-antivirus/clamav/files/clamav-0.99.3-VMSF_DELTA-fix-CVE-2012-6706.patch b/app-antivirus/clamav/files/clamav-0.99.3-VMSF_DELTA-fix-CVE-2012-6706.patch deleted file mode 100644 index 90facf6eae06..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.3-VMSF_DELTA-fix-CVE-2012-6706.patch +++ /dev/null @@ -1,186 +0,0 @@ -Apply proposed changes to fix RAR VMSF_DELTA Filter Signedness error (CVE-2012-6706) - -Cherry picked from commit a7d8447bd9a4d5ae1fa970c1849c8caeb5f1a805 [Link 1] and -d4699442bce76574573dc564e7f2177d679b88bd [Link 2]. - -Link 1: https://github.com/Cisco-Talos/clamav-devel/commit/a7d8447bd9a4d5ae1fa970c1849c8caeb5f1a805 -Link 2: https://github.com/Cisco-Talos/clamav-devel/commit/d4699442bce76574573dc564e7f2177d679b88bd - ---- a/libclamunrar/unrarvm.c -+++ b/libclamunrar/unrarvm.c -@@ -213,17 +213,20 @@ void rarvm_addbits(rarvm_input_t *rarvm_input, int bits) - - unsigned int rarvm_getbits(rarvm_input_t *rarvm_input) - { -- unsigned int bit_field; -+ unsigned int bit_field = 0; - -- if (rarvm_input->in_addr+2 < rarvm_input->buf_size) { -+ if (rarvm_input->in_addr < rarvm_input->buf_size) { - bit_field = (unsigned int) rarvm_input->in_buf[rarvm_input->in_addr] << 16; -- bit_field |= (unsigned int) rarvm_input->in_buf[rarvm_input->in_addr+1] << 8; -- bit_field |= (unsigned int) rarvm_input->in_buf[rarvm_input->in_addr+2]; -- bit_field >>= (8-rarvm_input->in_bit); -- -- return (bit_field & 0xffff); -+ if (rarvm_input->in_addr+1 < rarvm_input->buf_size) { -+ bit_field |= (unsigned int) rarvm_input->in_buf[rarvm_input->in_addr+1] << 8; -+ if (rarvm_input->in_addr+2 < rarvm_input->buf_size) { -+ bit_field |= (unsigned int) rarvm_input->in_buf[rarvm_input->in_addr+2]; -+ } -+ } - } -- return 0; -+ bit_field >>= (8-rarvm_input->in_bit); -+ -+ return (bit_field & 0xffff); - } - - unsigned int rarvm_read_data(rarvm_input_t *rarvm_input) -@@ -311,10 +314,10 @@ static unsigned int *rarvm_get_operand(rarvm_data_t *rarvm_data, - } - } - --static unsigned int filter_itanium_getbits(unsigned char *data, int bit_pos, int bit_count) -+static unsigned int filter_itanium_getbits(unsigned char *data, unsigned int bit_pos, unsigned int bit_count) - { -- int in_addr=bit_pos/8; -- int in_bit=bit_pos&7; -+ unsigned int in_addr=bit_pos/8; -+ unsigned int in_bit=bit_pos&7; - unsigned int bit_field=(unsigned int)data[in_addr++]; - bit_field|=(unsigned int)data[in_addr++] << 8; - bit_field|=(unsigned int)data[in_addr++] << 16; -@@ -323,10 +326,10 @@ static unsigned int filter_itanium_getbits(unsigned char *data, int bit_pos, int - return(bit_field & (0xffffffff>>(32-bit_count))); - } - --static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field, int bit_pos, int bit_count) -+static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field, unsigned int bit_pos, unsigned int bit_count) - { -- int i, in_addr=bit_pos/8; -- int in_bit=bit_pos&7; -+ unsigned int i, in_addr=bit_pos/8; -+ unsigned int in_bit=bit_pos&7; - unsigned int and_mask=0xffffffff>>(32-bit_count); - and_mask=~(and_mask<<in_bit); - -@@ -343,11 +346,12 @@ static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field, - static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_filters_t filter_type) - { - unsigned char *data, cmp_byte2, cur_byte, *src_data, *dest_data; -- int i, j, data_size, channels, src_pos, dest_pos, border, width, PosR; -- int op_type, cur_channel, byte_count, start_pos, pa, pb, pc; -+ unsigned int i, j, data_size, channels, src_pos, dest_pos, border, width, PosR; -+ unsigned int op_type, cur_channel, byte_count, start_pos; -+ int pa, pb, pc; - unsigned int file_offset, cur_pos, predicted; -- int32_t offset, addr; -- const int file_size=0x1000000; -+ uint32_t offset, addr; -+ const unsigned int file_size=0x1000000; - - switch(filter_type) { - case VMSF_E8: -@@ -356,7 +360,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - data_size = rarvm_data->R[4]; - file_offset = rarvm_data->R[6]; - -- if (((unsigned int)data_size >= VM_GLOBALMEMADDR) || (data_size < 4)) { -+ if ((data_size > VM_GLOBALMEMADDR) || (data_size < 4)) { - break; - } - -@@ -367,12 +371,14 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - if (cur_byte==0xe8 || cur_byte==cmp_byte2) { - offset = cur_pos+file_offset; - addr = GET_VALUE(FALSE, data); -- if (addr < 0) { -- if (addr+offset >=0 ) { -+ // We check 0x80000000 bit instead of '< 0' comparison -+ // not assuming int32 presence or uint size and endianness. -+ if ((addr & 0x80000000)!=0) { // addr<0 -+ if (((addr+offset) & 0x80000000)==0) { // addr+offset>=0 - SET_VALUE(FALSE, data, addr+file_size); - } - } else { -- if (addr<file_size) { -+ if (((addr-file_size) & 0x80000000)!=0) { // addr<file_size - SET_VALUE(FALSE, data, addr-offset); - } - } -@@ -386,7 +392,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - data_size = rarvm_data->R[4]; - file_offset = rarvm_data->R[6]; - -- if (((unsigned int)data_size >= VM_GLOBALMEMADDR) || (data_size < 21)) { -+ if ((data_size > VM_GLOBALMEMADDR) || (data_size < 21)) { - break; - } - -@@ -429,7 +435,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - border = data_size*2; - - SET_VALUE(FALSE, &rarvm_data->mem[VM_GLOBALMEMADDR+0x20], data_size); -- if ((unsigned int)data_size >= VM_GLOBALMEMADDR/2) { -+ if (data_size > VM_GLOBALMEMADDR/2 || channels > 1024 || channels == 0) { - break; - } - for (cur_channel=0 ; cur_channel < channels ; cur_channel++) { -@@ -440,7 +446,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - } - break; - case VMSF_RGB: { -- const int channels=3; -+ const unsigned int channels=3; - data_size = rarvm_data->R[4]; - width = rarvm_data->R[0] - 3; - PosR = rarvm_data->R[1]; -@@ -448,15 +454,14 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - dest_data = src_data + data_size; - - SET_VALUE(FALSE, &rarvm_data->mem[VM_GLOBALMEMADDR+0x20], data_size); -- if ((unsigned int)data_size >= VM_GLOBALMEMADDR/2) { -+ if (data_size > VM_GLOBALMEMADDR/2 || data_size < 3 || width > data_size || PosR > 2) { - break; - } - for (cur_channel=0 ; cur_channel < channels; cur_channel++) { - unsigned int prev_byte = 0; - for (i=cur_channel ; i<data_size ; i+=channels) { -- int upper_pos=i-width; -- if (upper_pos >= 3) { -- unsigned char *upper_data = dest_data+upper_pos; -+ if (i >= width+3) { -+ unsigned char *upper_data = dest_data+i-width; - unsigned int upper_byte = *upper_data; - unsigned int upper_left_byte = *(upper_data-3); - predicted = prev_byte+upper_byte-upper_left_byte; -@@ -486,13 +491,14 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - break; - } - case VMSF_AUDIO: { -- int channels=rarvm_data->R[0]; -+ unsigned int channels=rarvm_data->R[0]; - data_size = rarvm_data->R[4]; - src_data = rarvm_data->mem; - dest_data = src_data + data_size; - - SET_VALUE(FALSE, &rarvm_data->mem[VM_GLOBALMEMADDR+0x20], data_size); -- if ((unsigned int)data_size >= VM_GLOBALMEMADDR/2) { -+ // In fact, audio channels never exceed 4. -+ if (data_size > VM_GLOBALMEMADDR/2 || channels > 128 || channels == 0) { - break; - } - for (cur_channel=0 ; cur_channel < channels ; cur_channel++) { -@@ -553,7 +559,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil - data_size = rarvm_data->R[4]; - src_pos = 0; - dest_pos = data_size; -- if ((unsigned int)data_size >= VM_GLOBALMEMADDR/2) { -+ if (data_size > VM_GLOBALMEMADDR/2) { - break; - } - while (src_pos < data_size) { --- -2.16.2 - diff --git a/app-antivirus/clamav/files/clamav-0.99.3-fix-fd-leaks-in-cli_scanscript.patch b/app-antivirus/clamav/files/clamav-0.99.3-fix-fd-leaks-in-cli_scanscript.patch deleted file mode 100644 index a457a71758c6..000000000000 --- a/app-antivirus/clamav/files/clamav-0.99.3-fix-fd-leaks-in-cli_scanscript.patch +++ /dev/null @@ -1,132 +0,0 @@ -Author: Manuel Mausz <manuel-clamav@mausz.at> - -http://lists.clamav.net/pipermail/clamav-users/2018-January/005687.html - ---- clamav-0.99.3/libclamav/scanners.c.orig 2018-01-26 14:35:23.299386703 +0100 -+++ clamav-0.99.3/libclamav/scanners.c 2018-01-26 14:47:44.422451335 +0100 -@@ -1342,39 +1342,35 @@ - return CL_CLEAN; - } - -- /* dump to disk only if explicitly asked to -- * or if necessary to check relative offsets, -- * otherwise we can process just in-memory */ -- if(ctx->engine->keeptmp || (troot && troot->ac_reloff_num > 0)) { -- if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { -- cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); -- return ret; -- } -- if (ctx->engine->keeptmp) -- cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); -- } -- - if(!(normalized = cli_malloc(SCANBUFF + maxpatlen))) { - cli_dbgmsg("cli_scanscript: Unable to malloc %u bytes\n", SCANBUFF); -- free(tmpname); - return CL_EMEM; - } -- - text_normalize_init(&state, normalized, SCANBUFF + maxpatlen); -- ret = CL_CLEAN; -- - - if ((ret = cli_ac_initdata(&tmdata, troot?troot->ac_partsigs:0, troot?troot->ac_lsigs:0, troot?troot->ac_reloff_num:0, CLI_DEFAULT_AC_TRACKLEN))) { -- free(tmpname); -+ free(normalized); - return ret; - } - - if ((ret = cli_ac_initdata(&gmdata, groot->ac_partsigs, groot->ac_lsigs, groot->ac_reloff_num, CLI_DEFAULT_AC_TRACKLEN))) { - cli_ac_freedata(&tmdata); -- free(tmpname); -+ free(normalized); - return ret; - } - -+ /* dump to disk only if explicitly asked to -+ * or if necessary to check relative offsets, -+ * otherwise we can process just in-memory */ -+ if(ctx->engine->keeptmp || (troot && troot->ac_reloff_num > 0)) { -+ if((ret = cli_gentempfd(ctx->engine->tmpdir, &tmpname, &ofd))) { -+ cli_dbgmsg("cli_scanscript: Can't generate temporary file/descriptor\n"); -+ goto done; -+ } -+ if (ctx->engine->keeptmp) -+ cli_dbgmsg("cli_scanscript: saving normalized file to %s\n", tmpname); -+ } -+ - mdata[0] = &tmdata; - mdata[1] = &gmdata; - -@@ -1388,9 +1384,8 @@ - - if (write(ofd, state.out, state.out_pos) == -1) { - cli_errmsg("cli_scanscript: can't write to file %s\n",tmpname); -- close(ofd); -- free(tmpname); -- return CL_EWRITE; -+ ret = CL_EWRITE; -+ goto done; - } - text_normalize_reset(&state); - } -@@ -1409,11 +1404,6 @@ - funmap(*ctx->fmap); - } - *ctx->fmap = map; -- -- /* If we aren't keeping temps, delete the normalized file after scan. */ -- if(!(ctx->engine->keeptmp)) -- if (cli_unlink(tmpname)) ret = CL_EUNLINK; -- - } else { - /* Since the above is moderately costly all in all, - * do the old stuff if there's no relative offsets. */ -@@ -1421,11 +1411,8 @@ - if (troot) { - cli_targetinfo(&info, 7, map); - ret = cli_ac_caloff(troot, &tmdata, &info); -- if (ret) { -- cli_ac_freedata(&tmdata); -- free(tmpname); -- return ret; -- } -+ if (ret) -+ goto done; - } - - while(1) { -@@ -1466,13 +1453,6 @@ - - } - -- if(ctx->engine->keeptmp) { -- free(tmpname); -- if (ofd >= 0) -- close(ofd); -- } -- free(normalized); -- - if(ret != CL_VIRUS || SCAN_ALL) { - if ((ret = cli_exp_eval(ctx, troot, &tmdata, NULL, NULL)) == CL_VIRUS) - viruses_found++; -@@ -1481,9 +1461,19 @@ - viruses_found++; - } - -+done: -+ free(normalized); - cli_ac_freedata(&tmdata); - cli_ac_freedata(&gmdata); - -+ if (ofd != -1) -+ close(ofd); -+ if (tmpname != NULL) { -+ if (!ctx->engine->keeptmp) -+ if (cli_unlink(tmpname)) ret = CL_EUNLINK; -+ free(tmpname); -+ } -+ - if (SCAN_ALL && viruses_found) - return CL_VIRUS; - |