[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#776884: marked as done (wheezy-pu: clamav/0.98.6+dfsg-0+deb7u1)



Your message dated Sat, 05 Sep 2015 14:33:54 +0100
with message-id <1441460034.2151.33.camel@adam-barratt.org.uk>
and subject line Closing bugs for 7.9
has caused the Debian Bug report #776884,
regarding wheezy-pu: clamav/0.98.6+dfsg-0+deb7u1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
776884: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776884
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
Tags: wheezy
User: release.debian.org@packages.debian.org
Usertags: pu

Dear release team:

Please unblock the new clamav release which is a security release +
embedded libsmspack security release.
This is what we have in unstable without the systemd support and
"clamdscan" package split.

tl;dr

There is a new security based clamav release which I would like to
upload to wheezy. Here is the upstream NEWS:
|    - library shared object revisions.
|    - installation issues on some Mac OS X and FreeBSD platforms.
|    - includes a patch from Sebastian Andrzej Siewior making
|      ClamAV pid files compatible with systemd.
|    - Fix a heap out of bounds condition with crafted Yoda's
|      crypter files. This issue was discovered by Felix Groebert
|      of the Google Security Team.
|    - Fix a heap out of bounds condition with crafted mew packer
|      files. This issue was discovered by Felix Groebert of the
|      Google Security Team.
|    - Fix a heap out of bounds condition with crafted upx packer
|      files. This issue was discovered by Kevin Szkudlapski of
|      Quarkslab.
|    - Fix a heap out of bounds condition with crafted upack packer
|      files. This issue was discovered by Sebastian Andrzej Siewior.
|      CVE-2014-9328.
|    - Compensate a crash due to incorrect compiler optimization when
|      handling crafted petite packer files. This issue was discovered
|      by Sebastian Andrzej Siewior.

I would write an announcement for the CVE once it made it into pu (there 
was none yet). The other look like a CVE wouldn't hurt :)

Aside from clamav update I updated the internal libmspack library. The
official announcement for the new library version was:
|The main changes are fixes in handling invalid files, which were found by
|Debian researchers using the American fuzzy lop (afl) tool.
|
| * CVE-2014-9556: A CAB file with invalid file offset or length (where
|   offset + length == 2^32) causes an infinite loop in the Quantum decoder
|   on 32-bit architectures. [Debian bugs #772891, #773041]
| * A CAB file with two folders, the second folder invalid, and a file
|   decompression order of folder 1, 2, 1, causes execution to jump to NULL.
|   [Debian bugs #773659, #774665]
| * A CHM file with reset interval of zero causes division by zero. [Debian
|   bug #774725]
| * A CHM file with invalid name lengths in PGML/PGMI blocks causes
|   over-read and segfaults on 32-bit architecture [Debian bugs #774726,
|   #775687]
| * A CAB file with MSZIP-compressed data and a distance code of 30 causes a
|   1 byte over-read [Debian bug #775498]
| * A CAB file with zero-length filenames causes a 1 byte over-read.
| * A CAB file with invalid UTF-8 encoded filenames causes over-read of up
|   to 5 bytes.
| * A CAB or CHM file with LZX-compressed data ending early during an
|   odd-sized uncompressed block can cause a 1-byte under-read. [Debian bug
|   #775499]
|
|These issues have been fixed.
|
|Additionally, cabextract and libmspack's mschm_decompressor::fast_find now
|have more robust handling of invalid UTF-8 encoded filenames, and the bundled
|extra script wince_rename now creates files' install directories.

The last pu update fixed all the critical bugs (critical as in hang/crash) except
for #775687. The Debian Maintainer of the library already uploaded it
for unstable and asked for an unblock for testing.

The debdiff is huge, 24MiB. One reason is that we no longer purge the
llvm source from the .orig archive (but it remains unused because we
link against the external package). Its been left in source because
older Ubuntu needs it. Since a few patches got integrated upstream,
the patches in debian/patches got renamed by git-dpm and it is hardly
usefull.
Instead please find attached the output of
|	git diff -M debian-0.98.5+dfsg-0+deb7u3
with 
- libclamav/c++/llvm/* removed (as explained)
- debian/patches/* removed, the applied patches are part of the diff
- docs/html/*.html removed, a lot of "s/Cisco 2014-11-12/Cisco 2014-11-21/"
  and version update
- the files
   libclamav/libmspack-0.5alpha/Makefile.in
   libclamav/libmspack-0.5alpha/aclocal.m4
   libclamav/libmspack-0.5alpha/compile
   libclamav/libmspack-0.5alpha/config.guess
   libclamav/libmspack-0.5alpha/config.sub
   libclamav/libmspack-0.5alpha/configure
   libclamav/libmspack-0.5alpha/depcomp
   libclamav/libmspack-0.5alpha/install-sh
   libclamav/libmspack-0.5alpha/missing

  because huge and part of libmspack upstream autoreconf run.

The result is attached and 147 KiB in size.

Sebastian
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,44 @@
+
+Tue Dec 16 16:21:40 2014 EDT (swebb)
+-------------------------------------
+bb#11215 - Change a variable to be an unsigned int to compensate for
+	compiler optimization issue with crafted petite file. Fix
+	suggested by Sebastian Andrzej Siewior.
+
+Fri Dec 12 14:33:41 2014 EDT (klin)
+-----------------------------------
+Added missing break statements(FireAmp #12710) to correct handling of
+	prescan callback return code.
+
+Fri Dec 5 15:26:06 2014 EDT (smorgan)
+-------------------------------------
+bb#11216 - add boundary checks for fuzzed upack file. This issue
+	was reported by Sebastian Andrzej Siewior. CVE-2014-9328.
+
+Thu Dec 4 18:29:17 2014 EDT (klin)
+-----------------------------------
+bb#11212 - fixed section boundary mismatch in MEW unpacker. This issue
+	was identified by Felix Groebert of the Google Security Team.
+
+Thu Dec 4 08:43:43 2014 EDT (swebb)
+-------------------------------------
+bb#11213 - Enforce bounds checking before integer overflow in upx files.
+	This issue was reported by Kevin Szkudlapski of Quarkslab.
+
+Tue Dec 2 15:15:55 2014 EDT (swebb)
+-------------------------------------
+bb#11210: Apply a basic fix for y0da crafted file. This issue was
+	identified by Felix Groebert of the Google Security Team.
+
+Fri, 21 Nov 2014 15:55:12 EDT (swebb)
+-------------------------------------
+bb#11194: Include OpenSSL's headers after the local headers
+
+Thu, 20 Nov 2014 12:39:00 EDT (swebb)
+-------------------------------------
+bb#10907: Add trailing newline to the end of the pidfile
+	  (patch submitted by Sebastian Andrzej Siewior)
+
 Wed, 12 Nov 2014 14:30:39 EDT (swebb)
 -------------------------------------
 * bb11176 - Instruct OpenSSL to allow MD5 when in FIPS-compliant mode.
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,49 +1,36 @@
-0.98.5
+0.98.6
 ------
 
-Welcome to ClamAV 0.98.5! ClamAV 0.98.5 includes important new features
-for collecting and analyzing file properties. Software developers and
-analysts may collect file property meta data using the ClamAV API for
-subsequent analysis by ClamAV bytecode programs. Using these features
-will require that libjson-c is installed, but otherwise libjson-c is not
-needed.
-
-Look for our upcoming series of blog posts to learn more about using the
-ClamAV API and bytecode facilities for collecting and analyzing file
-properties.
-
-ClamAV 0.98.5 also includes these new features and bug fixes:
-
-    - Support for the XDP file format and extracting, decoding, and
-      scanning PDF files within XDP files.
-    - Addition of shared library support for LLVM versions 3.1 - 3.5
-      for the purpose of just-in-time(JIT) compilation of ClamAV
-      bytecode signatures. Andreas Cadhalpun submitted the patch
-      implementing this support.
-    - Enhancements to the clambc command line utility to assist
-      ClamAV bytecode signature authors by providing introspection
-      into compiled bytecode programs.
-    - Resolution of many of the warning messages from ClamAV compilation.
-    - Improved detection of malicious PE files.
-    - Security fix for ClamAV crash when using 'clamscan -a'. This issue
-      was identified by Kurt Siefried of Red Hat.
-    - Security fix for ClamAV crash when scanning maliciously crafted
-      yoda's crypter files. This issue, as well as several other bugs
-      fixed in this release, were identified by Damien Millescamp of
-      Oppida.
-    - ClamAV 0.98.5 now works with OpenSSL in FIPS compliant mode.
-      Thanks to Reinhard Max for supplying the patch.
-    - Bug fixes and other feature enhancements. See Changelog or
-      git log for details.
+ClamAV 0.98.6 is a bug fix release correcting the following:
 
+    - library shared object revisions.
+    - installation issues on some Mac OS X and FreeBSD platforms.
+    - includes a patch from Sebastian Andrzej Siewior making
+      ClamAV pid files compatible with systemd.
+    - Fix a heap out of bounds condition with crafted Yoda's
+      crypter files. This issue was discovered by Felix Groebert
+      of the Google Security Team.
+    - Fix a heap out of bounds condition with crafted mew packer
+      files. This issue was discovered by Felix Groebert of the
+      Google Security Team.
+    - Fix a heap out of bounds condition with crafted upx packer
+      files. This issue was discovered by Kevin Szkudlapski of
+      Quarkslab.
+    - Fix a heap out of bounds condition with crafted upack packer
+      files. This issue was discovered by Sebastian Andrzej Siewior.
+      CVE-2014-9328.
+    - Compensate a crash due to incorrect compiler optimization when
+      handling crafted petite packer files. This issue was discovered
+      by Sebastian Andrzej Siewior.
+      
 Thanks to the following ClamAV community members for code submissions
-and bug reporting included in ClamAV 0.98.5:
+and bug reporting included in ClamAV 0.98.6:
 
-Andreas Cadhalpun
 Sebastian Andrzej Siewior
-Damien Millescamp
-Reinhard Max
-Kurt Seifried
+Felix Groebert
+Kevin Szkudlapski
+Mark Pizzolato
+Daniel J. Luke
 
 --
 The ClamAV team (http://www.clamav.net/about.html#credits)
diff --git a/README b/README
--- a/README
+++ b/README
@@ -2,6 +2,40 @@ Note: This README/NEWS file refers to the source tarball. Some things described
 here may not be available in binary packages.
 --
 
+0.98.6
+------
+
+ClamAV 0.98.6 is a bug fix release correcting the following:
+
+    - library shared object revisions.
+    - installation issues on some Mac OS X and FreeBSD platforms.
+    - includes a patch from Sebastian Andrzej Siewior making
+      ClamAV pid files compatible with systemd.
+    - Fix a heap out of bounds condition with crafted Yoda's
+      crypter files. This issue was discovered by Felix Groebert
+      of the Google Security Team.
+    - Fix a heap out of bounds condition with crafted mew packer
+      files. This issue was discovered by Felix Groebert of the
+      Google Security Team.
+    - Fix a heap out of bounds condition with crafted upx packer
+      files. This issue was discovered by Kevin Szkudlapski of
+      Quarkslab.
+    - Fix a heap out of bounds condition with crafted upack packer
+      files. This issue was discovered by Sebastian Andrzej Siewior.
+      CVE-2014-9328.
+    - Compensate a crash due to incorrect compiler optimization when
+      handling crafted petite packer files. This issue was discovered
+      by Sebastian Andrzej Siewior.
+      
+Thanks to the following ClamAV community members for code submissions
+and bug reporting included in ClamAV 0.98.6:
+
+Sebastian Andrzej Siewior
+Felix Groebert
+Kevin Szkudlapski
+Mark Pizzolato
+Daniel J. Luke
+
 0.98.5
 ------
 
diff --git a/clamav-milter/Makefile.am b/clamav-milter/Makefile.am
--- a/clamav-milter/Makefile.am
+++ b/clamav-milter/Makefile.am
@@ -47,5 +47,5 @@ endif
 
 DEFS = @DEFS@ -DCL_NOLIBCLAMAV
 LIBS = $(top_builddir)/libclamav/libclamav_internal_utils.la @CLAMAV_MILTER_LIBS@ @THREAD_LIBS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir) @JSON_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir) @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
 CLEANFILES=*.gcda *.gcno
diff --git a/clamav-milter/Makefile.in b/clamav-milter/Makefile.in
--- a/clamav-milter/Makefile.in
+++ b/clamav-milter/Makefile.in
@@ -504,7 +504,7 @@ top_srcdir = @top_srcdir@
 
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@man_MANS = $(top_builddir)/docs/man/clamav-milter.8
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@AM_CFLAGS = @WERR_CFLAGS_MILTER@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir) @JSON_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared -I$(top_srcdir) @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
 CLEANFILES = *.gcda *.gcno
 all: all-am
 
diff --git a/clamd/Makefile.am b/clamd/Makefile.am
--- a/clamd/Makefile.am
+++ b/clamd/Makefile.am
@@ -53,7 +53,7 @@ AM_CFLAGS=@WERR_CFLAGS@
 endif
 
 LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @THREAD_LIBS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
 
 # it does support --help and --version but with the default config file
 # it outputs an error message which tells us to edit the config files
diff --git a/clamd/Makefile.in b/clamd/Makefile.in
--- a/clamd/Makefile.in
+++ b/clamd/Makefile.in
@@ -479,7 +479,7 @@ top_srcdir = @top_srcdir@
 @BUILD_CLAMD_TRUE@    fan.h
 
 @BUILD_CLAMD_TRUE@AM_CFLAGS = @WERR_CFLAGS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
 
 # it does support --help and --version but with the default config file
 # it outputs an error message which tells us to edit the config files
diff --git a/clamd/scanner.c b/clamd/scanner.c
--- a/clamd/scanner.c
+++ b/clamd/scanner.c
@@ -119,7 +119,6 @@ int scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ftw_rea
 
     /* detect disconnected socket, 
      * this should NOT detect half-shutdown sockets (SHUT_WR) */
-#if !defined(__GNU__)
     if (send(scandata->conn->sd, &ret, 0, 0) == -1 && errno != EINTR) {
 	logg("$Client disconnected while command was active!\n");
 	thrmgr_group_terminate(scandata->conn->group);
@@ -127,7 +126,7 @@ int scan_callback(STATBUF *sb, char *filename, const char *msg, enum cli_ftw_rea
 	    free(filename);
 	return CL_BREAK;
     }
-#endif
+
     if (thrmgr_group_need_terminate(scandata->conn->group)) {
 	logg("^Client disconnected while scanjob was active\n");
 	if (reason == visit_file)
diff --git a/clamd/tcpserver.c b/clamd/tcpserver.c
--- a/clamd/tcpserver.c
+++ b/clamd/tcpserver.c
@@ -112,8 +112,11 @@ int tcpserver(int **lsockets, unsigned int *nlsockets, char *ipaddr, const struc
             serv[0] = '\0';
         }
 #else
-        strncpy(host, ipaddr, sizeof(host));
-        host[sizeof(host)-1] = '\0';
+		if (ipaddr) {
+			strncpy(host, ipaddr, sizeof(host));
+			host[sizeof(host)-1] = '\0';
+		} else
+			host[0] = '\0';
         snprintf(serv, sizeof(serv), "%u", (unsigned int)(optget(opts, "TCPSocket")->numarg));
 #endif
         if(bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
diff --git a/clamdscan/Makefile.am b/clamdscan/Makefile.am
--- a/clamdscan/Makefile.am
+++ b/clamdscan/Makefile.am
@@ -44,7 +44,7 @@ endif
 
 
 DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CLAMDSCAN_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CLAMDSCAN_CPPFLAGS@ @JSON_CPPFLAGS@
 LIBS = $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la  @CLAMDSCAN_LIBS@
 
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamdscan$(EXEEXT)
diff --git a/clamdscan/Makefile.in b/clamdscan/Makefile.in
--- a/clamdscan/Makefile.in
+++ b/clamdscan/Makefile.in
@@ -468,7 +468,7 @@ top_srcdir = @top_srcdir@
 @BUILD_CLAMD_TRUE@    client.h
 
 @BUILD_CLAMD_TRUE@AM_CFLAGS = @WERR_CFLAGS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CLAMDSCAN_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CLAMDSCAN_CPPFLAGS@ @JSON_CPPFLAGS@
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamdscan$(EXEEXT)
 CLEANFILES = *.gcda *.gcno
 all: all-am
diff --git a/clamdscan/proto.c b/clamdscan/proto.c
--- a/clamdscan/proto.c
+++ b/clamdscan/proto.c
@@ -99,10 +99,9 @@ int dconnect() {
         memset(&hints, 0x00, sizeof(struct addrinfo));
         hints.ai_family = AF_UNSPEC;
         hints.ai_socktype = SOCK_STREAM;
-        hints.ai_flags = AI_PASSIVE;
 
         if ((res = getaddrinfo(ipaddr, port, &hints, &info))) {
-            logg("!Could not lookup %s: %s\n", opt->strarg, gai_strerror(res));
+            logg("!Could not lookup %s: %s\n", ipaddr ? ipaddr : "", gai_strerror(res));
             opt = opt->nextarg;
             continue;
         }
diff --git a/clamdtop/Makefile.am b/clamdtop/Makefile.am
--- a/clamdtop/Makefile.am
+++ b/clamdtop/Makefile.am
@@ -11,8 +11,8 @@ clamdtop_SOURCES = \
     clamdtop.c
 
 AM_CFLAGS=@WERR_CFLAGS@
-AM_CPPFLAGS = -I$(top_srcdir) @CURSES_CPPFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
-clamdtop_LDADD = @CURSES_LIBS@ @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CURSES_CPPFLAGS@ @JSON_CPPFLAGS@
+clamdtop_LDADD = @SSL_LDFLAGS@ @SSL_LIBS@ @CURSES_LIBS@ $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
 endif
 DEFS = @DEFS@ -DCL_NOTHREADS -DCL_NOLIBCLAMAV
 EXTRA_DIST = clamdtop.c
diff --git a/clamdtop/Makefile.in b/clamdtop/Makefile.in
--- a/clamdtop/Makefile.in
+++ b/clamdtop/Makefile.in
@@ -465,8 +465,8 @@ top_srcdir = @top_srcdir@
 @HAVE_CURSES_TRUE@    clamdtop.c
 
 @HAVE_CURSES_TRUE@AM_CFLAGS = @WERR_CFLAGS@
-@HAVE_CURSES_TRUE@AM_CPPFLAGS = -I$(top_srcdir) @CURSES_CPPFLAGS@ @SSL_CPPFLAGS@ @JSON_CPPFLAGS@
-@HAVE_CURSES_TRUE@clamdtop_LDADD = @CURSES_LIBS@ @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
+@HAVE_CURSES_TRUE@AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @CURSES_CPPFLAGS@ @JSON_CPPFLAGS@
+@HAVE_CURSES_TRUE@clamdtop_LDADD = @SSL_LDFLAGS@ @SSL_LIBS@ @CURSES_LIBS@ $(top_builddir)/libclamav/libclamav_internal_utils_nothreads.la
 EXTRA_DIST = clamdtop.c
 all: all-am
 
diff --git a/clamscan/Makefile.am b/clamscan/Makefile.am
--- a/clamscan/Makefile.am
+++ b/clamscan/Makefile.am
@@ -38,6 +38,6 @@ clamscan_SOURCES = \
 AM_CFLAGS=@WERR_CFLAGS@
 DEFS = @DEFS@ -DCL_NOTHREADS
 LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@ @CLAMSCAN_LIBS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CLAMSCAN_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @CLAMSCAN_CPPFLAGS@
 
 CLEANFILES=*.gcda *.gcno
diff --git a/clamscan/Makefile.in b/clamscan/Makefile.in
--- a/clamscan/Makefile.in
+++ b/clamscan/Makefile.in
@@ -456,7 +456,7 @@ clamscan_SOURCES = \
     manager.h
 
 AM_CFLAGS = @WERR_CFLAGS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @CLAMSCAN_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @CLAMSCAN_CPPFLAGS@
 CLEANFILES = *.gcda *.gcno
 all: all-am
 
diff --git a/clamsubmit/Makefile.am b/clamsubmit/Makefile.am
--- a/clamsubmit/Makefile.am
+++ b/clamsubmit/Makefile.am
@@ -31,7 +31,7 @@ clamsubmit_SOURCES = \
 
 AM_CFLAGS=@WERR_CFLAGS@ @CLAMSUBMIT_CFLAGS@
 DEFS = @DEFS@ -DCL_NOTHREADS
-AM_CPPFLAGS = @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @JSON_CPPFLAGS@
 LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMSUBMIT_LIBS@ @THREAD_LIBS@
 
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamsubmit$(EXEEXT)
diff --git a/clamsubmit/Makefile.in b/clamsubmit/Makefile.in
--- a/clamsubmit/Makefile.in
+++ b/clamsubmit/Makefile.in
@@ -449,7 +449,7 @@ clamsubmit_SOURCES = \
 	clamsubmit.c
 
 AM_CFLAGS = @WERR_CFLAGS@ @CLAMSUBMIT_CFLAGS@
-AM_CPPFLAGS = @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @JSON_CPPFLAGS@
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = clamsubmit$(EXEEXT)
 CLEANFILES = *.gcda *.gcno
 all: all-am
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ClamAV 0.98.5.
+# Generated by GNU Autoconf 2.69 for ClamAV 0.98.6.
 #
 # Report bugs to <http://bugs.clamav.net/>.
 #
@@ -592,8 +592,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ClamAV'
 PACKAGE_TARNAME='clamav'
-PACKAGE_VERSION='0.98.5'
-PACKAGE_STRING='ClamAV 0.98.5'
+PACKAGE_VERSION='0.98.6'
+PACKAGE_STRING='ClamAV 0.98.6'
 PACKAGE_BUGREPORT='http://bugs.clamav.net/'
 PACKAGE_URL='http://www.clamav.net/'
 
@@ -1468,7 +1468,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ClamAV 0.98.5 to adapt to many kinds of systems.
+\`configure' configures ClamAV 0.98.6 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1539,7 +1539,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ClamAV 0.98.5:";;
+     short | recursive ) echo "Configuration of ClamAV 0.98.6:";;
    esac
   cat <<\_ACEOF
 
@@ -1708,7 +1708,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ClamAV configure 0.98.5
+ClamAV configure 0.98.6
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2177,7 +2177,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ClamAV $as_me 0.98.5, which was
+It was created by ClamAV $as_me 0.98.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3346,7 +3346,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='clamav'
- VERSION='0.98.5'
+ VERSION='0.98.6'
 
 
 # Some tools Automake needs.
@@ -5087,10 +5087,10 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
 
 
 
-VERSION="0.98.5"
+VERSION="0.98.6"
 
 LC_CURRENT=7
-LC_REVISION=22
+LC_REVISION=25
 LC_AGE=1
 LIBCLAMAV_VERSION="$LC_CURRENT":"$LC_REVISION":"$LC_AGE"
 
@@ -23185,7 +23185,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ClamAV $as_me 0.98.5, which was
+This file was extended by ClamAV $as_me 0.98.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -23252,7 +23252,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ClamAV config.status 0.98.5
+ClamAV config.status 0.98.6
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -25825,7 +25825,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ClamAV $as_me 0.98.5, which was
+This file was extended by ClamAV $as_me 0.98.6, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -25892,7 +25892,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ClamAV config.status 0.98.5
+ClamAV config.status 0.98.6
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ dnl   MA 02110-1301, USA.
 AC_PREREQ([2.59])
 dnl For a release change [devel] to the real version [0.xy]
 dnl also change VERSION below
-AC_INIT([ClamAV], [0.98.5], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/])
+AC_INIT([ClamAV], [0.98.6], [http://bugs.clamav.net/], [clamav], [http://www.clamav.net/])
 
 AH_BOTTOM([#include "platform.h"])
 dnl put configure auxiliary into config
@@ -137,7 +137,7 @@ AM_CONDITIONAL([USE_INTERNAL_MSPACK], test "x$use_internal_mspack" = "xyes")
 
 if test "x$use_internal_mspack" = "xyes"; then
 	mspack_msg="Internal"
-	AC_CONFIG_SUBDIRS([libclamav/libmspack-0.4alpha])
+	AC_CONFIG_SUBDIRS([libclamav/libmspack-0.5alpha])
 else
 	mspack_msg="External, $LIBMSPACK_CFLAGS $LIBMSPACK_LIBS"
 fi
diff --git a/debian/.git-dpm b/debian/.git-dpm
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@ -1,8 +1,8 @@
 # see git-dpm(1) from git-dpm package
-1a5b9b3aba6e15f6c7371aa23adbc0600a0cf830
-1a5b9b3aba6e15f6c7371aa23adbc0600a0cf830
-14c3d5ca803fd6baa5ab413e87ca6d6bb2e26a3d
-14c3d5ca803fd6baa5ab413e87ca6d6bb2e26a3d
-clamav_0.98.5+dfsg.orig.tar.xz
-e7df5b8654c165afa4a299cb914c2d6afcf05788
-5286536
+ce66a24ca81dd6b361f413f1908f7f8e7c9c3012
+ce66a24ca81dd6b361f413f1908f7f8e7c9c3012
+f7da883ef235c6941ec2081e0107822dd7be35a9
+f7da883ef235c6941ec2081e0107822dd7be35a9
+clamav_0.98.6+dfsg.orig.tar.xz
+1ceb0814ecc8fb38800303da8ac75b09b9d7a16b
+8240960
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,47 @@
+clamav (0.98.6+dfsg-0+deb7u1) UNRELEASED; urgency=medium
+
+  [ Sebastian Andrzej Siewior ]
+  * New upstream bugfix release
+    - Library shared object revisions.
+    - Includes a patch from Sebastian Andrzej Siewior making ClamAV pid files
+      compatible with systemd.
+    - Fix a heap out of bounds condition with crafted Yoda's crypter files.
+      This issue was discovered by Felix Groebert of the Google Security Team.
+    - Fix a heap out of bounds condition with crafted mew packer files. This
+      issue was discovered by Felix Groebert of the Google Security Team.
+    - Fix a heap out of bounds condition with crafted upx packer files. This
+      issue was discovered by Kevin Szkudlapski of Quarkslab.
+    - Fix a heap out of bounds condition with crafted upack packer files. This
+      issue was discovered by Sebastian Andrzej Siewior. CVE-2014-9328.
+    - Compensate a crash due to incorrect compiler optimization when handling
+      crafted petite packer files. This issue was discovered by Sebastian
+      Andrzej Siewior.
+  * Update embedded libmspack from 0.4alpha to 0.5alpha (security bugfix
+    release)
+  * Don't leak return codes from libmspack to clamav API. (Closes: #774686).
+
+  [ Andreas Cadhalpun ]
+  * Drop Workaround-a-bug-in-libc-on-Hurd.patch, because hurd got fixed.
+    (see #752237)
+  * Update libclamav6: embedded-library lintian override for new libclamav6
+    and make it generic
+  * Update lintian-overrides for unused-file-paragraph-in-dep5-copyright.
+  * clamav-base.postinst: always chown /var/log/clamav and /var/lib/clamav
+    to clamav:clamav, not only on fresh installations. (Closes: #775400)
+  * debian/copyright: drop files from Files-Excluded only present in github
+    tarballs
+  * debian/rules: Remove useless --with-system-tommath --without-included-ltdl
+    configure options.
+
+  [ Scott Kitterman ]
+  * Stop stripping llvm when repacking the tarball as the system llvm on some
+    releases is too old to use
+
+  [ Javier Fernández-Sanguino ]
+  * Updated Spanish Debconf template translation (Closes: #773563)
+
+ -- Sebastian Andrzej Siewior <sebastian@breakpoint.cc>  Fri, 30 Jan 2015 22:42:31 +0100
+
 clamav (0.98.5+dfsg-0+deb7u3) stable; urgency=medium
 
   * add "mspack-fix-division-by-zero-in-chm-format-handling" to fix divide
diff --git a/debian/clamav-base.postinst.in b/debian/clamav-base.postinst.in
--- a/debian/clamav-base.postinst.in
+++ b/debian/clamav-base.postinst.in
@@ -35,8 +35,6 @@ case "$1" in
     adduser --system --no-create-home --quiet \
         --disabled-password --disabled-login \
 	--shell /bin/false --group --home /var/lib/clamav clamav
-    chown $user:$user $DATABASEDIR
-    chown $user:$user $LOGDIR
     if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
       if ! grep -qi "^clamav" /etc/aliases; then
         echo "clamav: root" >> /etc/aliases
@@ -47,6 +45,8 @@ case "$1" in
       fi
     fi
   fi
+  chown $user:$user $DATABASEDIR
+  chown $user:$user $LOGDIR
   ;;
   abort-upgrade|abort-remove|abort-deconfigure)
   ;;
diff --git a/debian/clamav-freshclam.lintian-overrides b/debian/clamav-freshclam.lintian-overrides
--- a/debian/clamav-freshclam.lintian-overrides
+++ b/debian/clamav-freshclam.lintian-overrides
@@ -1,2 +1,2 @@
 # This is not used by the maintainer script, only echoed to the cron job.
-clamav-freshclam: command-with-path-in-maintainer-script postinst:407 /usr/bin/freshclam
+clamav-freshclam: command-with-path-in-maintainer-script postinst:* /usr/bin/freshclam
diff --git a/debian/copyright b/debian/copyright
--- a/debian/copyright
+++ b/debian/copyright
@@ -9,13 +9,6 @@ Source: https://github.com/vrtadmin/clamav-devel
  The excluded files below just make the tarball unneccesarily large, or
  interfere with the version management.
 Files-Excluded:
- .gitattributes
- .gitignore
- */.gitignore
- docs/man/.gitignore
- contrib/*
- libclamav/c++/llvm/*
- llvm/*
  win32/*
 
 
@@ -749,7 +742,7 @@ License: public-domain
 Comment:
  See COPYING.lzma.
 
-Files: libclamav/libmspack-0.4alpha/*
+Files: libclamav/libmspack-0.5alpha/*
 Copyright:
  2003-2013, Stuart Caie
  2003-2013, Matthew Russotto
@@ -766,13 +759,13 @@ License: LGPL-2.1
  License version 2.1 can be found in the file
  `/usr/share/common-licenses/LGPL-2.1'.
 
-Files: libclamav/libmspack-0.4alpha/mspack/crc32.c
+Files: libclamav/libmspack-0.5alpha/mspack/crc32.c
 Copyright: 1986, Gary S. Brown
 License: permissive
  You may use this program, or code or tables extracted from it,
  as desired without restriction.
 
-Files: libclamav/libmspack-0.4alpha/test/md5.*
+Files: libclamav/libmspack-0.5alpha/test/md5.*
 Copyright: 1995, 1996, 1999, 2001, 2003 Free Software Foundation, Inc.
 License: GPL-2+
  This program is free software; you can redistribute it and/or modify it
@@ -794,12 +787,39 @@ License: GPL-2+
  version 2 can be found in the file `/usr/share/common-licenses/GPL-2'.
 
 Files:
- libclamav/libmspack-0.4alpha/config.guess
- libclamav/libmspack-0.4alpha/config.sub
- libclamav/libmspack-0.4alpha/depcomp
- libclamav/libmspack-0.4alpha/missing
+ libclamav/libmspack-0.5alpha/config.guess
+ libclamav/libmspack-0.5alpha/config.sub
 Copyright:
- 1992-2012, Free Software Foundation, Inc.
+ 1992-2013, Free Software Foundation, Inc.
+License: GPL-3+ with Autoconf exception
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ As a special exception to the GNU General Public License, if you
+ distribute this file as part of a program that contains a
+ configuration script generated by Autoconf, you may include it under
+ the same distribution terms that you use for the rest of that program.
+Comment:
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+ .
+ On Debian systems, the full text of the GNU General Public License
+ version 3 can be found in the file `/usr/share/common-licenses/GPL-3'.
+
+Files:
+ libclamav/libmspack-0.5alpha/depcomp
+ libclamav/libmspack-0.5alpha/missing
+Copyright:
+ 1992-2013, Free Software Foundation, Inc.
 License: GPL-2+ with Autoconf exception
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -824,7 +844,7 @@ License: GPL-2+ with Autoconf exception
  On Debian systems, the full text of the GNU General Public License
  version 2 can be found in the file `/usr/share/common-licenses/GPL-2'.
 
-Files: libclamav/libmspack-0.4alpha/ltmain.sh
+Files: libclamav/libmspack-0.5alpha/ltmain.sh
 Copyright:
  1996-2011, Free Software Foundation, Inc.
 License: GPL-2+ with Libtool exception
@@ -851,7 +871,7 @@ License: GPL-2+ with Libtool exception
  On Debian systems, the full text of the GNU General Public License
  version 2 can be found in the file `/usr/share/common-licenses/GPL-2'.
 
-Files: libclamav/libmspack-0.4alpha/install-sh
+Files: libclamav/libmspack-0.5alpha/install-sh
 Copyright:
  1994, X Consortium
 License: Expat
@@ -880,17 +900,17 @@ License: Expat
  FSF changes to this file are in the public domain.
 
 Files:
- libclamav/libmspack-0.4alpha/aclocal.m4
- libclamav/libmspack-0.4alpha/configure
- libclamav/libmspack-0.4alpha/Makefile.in
- libclamav/libmspack-0.4alpha/INSTALL
- libclamav/libmspack-0.4alpha/m4/libtool.m4
- libclamav/libmspack-0.4alpha/m4/lt~obsolete.m4
- libclamav/libmspack-0.4alpha/m4/ltoptions.m4
- libclamav/libmspack-0.4alpha/m4/ltsugar.m4
- libclamav/libmspack-0.4alpha/m4/ltversion.m4
+ libclamav/libmspack-0.5alpha/aclocal.m4
+ libclamav/libmspack-0.5alpha/configure
+ libclamav/libmspack-0.5alpha/Makefile.in
+ libclamav/libmspack-0.5alpha/INSTALL
+ libclamav/libmspack-0.5alpha/m4/libtool.m4
+ libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4
+ libclamav/libmspack-0.5alpha/m4/ltoptions.m4
+ libclamav/libmspack-0.5alpha/m4/ltsugar.m4
+ libclamav/libmspack-0.5alpha/m4/ltversion.m4
 Copyright:
- 1992-2011, Free Software Foundation, Inc.
+ 1992-2013, Free Software Foundation, Inc.
 License: permissive
  This file is free software; the Free Software Foundation gives
  unlimited permission to copy and/or distribute it, with or without
@@ -901,7 +921,7 @@ License: permissive
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.
 
-Files: libclamav/libmspack-0.4alpha/INSTALL
+Files: libclamav/libmspack-0.5alpha/INSTALL
 Copyright:
  1994-1996, 1999-2002, 2004-2011, Free Software Foundation, Inc.
 License: permissive
diff --git a/debian/libclamav6.lintian-overrides b/debian/libclamav6.lintian-overrides
--- a/debian/libclamav6.lintian-overrides
+++ b/debian/libclamav6.lintian-overrides
@@ -1,4 +1,4 @@
 # This is sort of a false positive, because libclamav uses the packaged zlib.
 # It still embeds a modified version of zlib to support 64 bit decompression,
 # which is not part of zlib, see #308799.
-libclamav6 binary: embedded-library usr/lib/libclamav.so.6.1.24: zlib
+libclamav6 binary: embedded-library usr/lib/libclamav.so.6.*: zlib
diff --git a/debian/po/es.po b/debian/po/es.po
--- a/debian/po/es.po
+++ b/debian/po/es.po
@@ -10,8 +10,8 @@
 # 	Ruben Porras <nahoo@inicia.es>
 #   	Javier Fernández-Sanguino <jfs@debian.org>
 #   
-# 	- Updates
-# 	Javier Fernández-Sanguino, 2006-2007
+#   - Updated by
+#       Javier Fernández-Sanguino, 2006-2007, 2014
 #       Omar Campagne <ocampagne@gmail.com>, 2010-2011
 #
 # Traductores, si no conocen el formato PO, merece la pena leer la
@@ -32,13 +32,19 @@
 #     /usr/share/doc/po-debconf/README-trans
 #     o http://www.debian.org/intl/l10n/po-debconf/README-trans
 #
+# Glosario
+# --------
+#
+# - malware - código malicioso
+# - virus   - virus
+#
 msgid ""
 msgstr ""
 "Project-Id-Version: clamav 0.96+dfsg-4\n"
 "Report-Msgid-Bugs-To: clamav@packages.debian.org\n"
 "POT-Creation-Date: 2014-05-10 23:12+0200\n"
-"PO-Revision-Date: 2011-07-03 18:45+0200\n"
-"Last-Translator: Omar Campagne <ocampagne@gmail.com>\n"
+"PO-Revision-Date: 2014-12-05 18:25+0100\n"
+"Last-Translator: Javier Fernández-Sanguino Peña <jfs@debian.org>\n"
 "Language-Team: Debian Spanish <debian-l10n-spanish@lists.debian.org>\n"
 "Language: es\n"
 "MIME-Version: 1.0\n"
@@ -46,6 +52,22 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 "X-Generator: Virtaal 0.7.0\n"
+"X-POFile-SpellExtra: LeaveTemporaryFiles gz tcp bytecode DNSDatabaseInfo\n"
+"X-POFile-SpellExtra: Clamav autenticode qQ safebrowsing Socket URL IPv\n"
+"X-POFile-SpellExtra: LogInfected daemon UUID xx Scanned Clamd VirusAction\n"
+"X-POFile-SpellExtra: From logs ScriptedUpdates Paranoid Since cron syslog\n"
+"X-POFile-SpellExtra: clamd TEMP TCP TrustSigned net run Mb\n"
+"X-POFile-SpellExtra: ALLMATCHSCAN clamav Modified proxy cvd bz on socket\n"
+"X-POFile-SpellExtra: phishing Sendmail pdf eth LogClean PID Freshclam unix\n"
+"X-POFile-SpellExtra: mailq PrivateMirror Reject sockets Status script\n"
+"X-POFile-SpellExtra: freshclam autocomprobaciones clamscan\n"
+"X-POFile-SpellExtra: SupportMultipleRecipients usr var inet OnInfected CLD\n"
+"X-POFile-SpellExtra: SMTP README Connection POSIX authenticode DNS dpkg\n"
+"X-POFile-SpellExtra: DatabaseMirror none deb root StreamMaxLength\n"
+"X-POFile-SpellExtra: reanalizar tar share SWF To conf CVD any chroot\n"
+"X-POFile-SpellExtra: ClamAV clamdoc Hostid http Postfix milter ifup CIDR\n"
+"X-POFile-SpellExtra: MTA autocomprobación Google off TMPDIR database doc\n"
+"X-POFile-SpellExtra: bytecodes If ésto\n"
 
 #. Type: select
 #. Choices
@@ -147,7 +169,7 @@ msgstr ""
 #. Description
 #: ../clamav-freshclam.templates:4001
 msgid "Please use URL syntax (\"http://host[:port]\";) here."
-msgstr "Utilice la sintaxis URL («http://equipo[:port]»;)."
+msgstr "Utilice la sintaxis URL («http://equipo[:puerto]»;)."
 
 #. Type: string
 #. Description
@@ -266,10 +288,8 @@ msgstr ""
 #. Type: boolean
 #. Description
 #: ../clamav-freshclam.templates:9001
-#, fuzzy
-#| msgid "Do you want to enable mail scanning?"
 msgid "Do you want to enable support for Google Safe Browsing?"
-msgstr "¿Desea activar el análisis del correo?"
+msgstr "¿Desea activar el soporte para la Navegación Segura de Google?"
 
 #. Type: boolean
 #. Description
@@ -283,21 +303,19 @@ msgid ""
 "option, it's mandatory to run freshclam at least every 30 minutes. Freshclam "
 "uses the ClamAV's mirror infrastructure to distribute the database and its "
 "updates but all the contents are provided under Google's terms of use."
-msgstr ""
+msgstr "Cuando se activa por primera vez, freshclam descargará un nuevo archivo de base de datos (safebrowsing.cvd) que se cargará automáticamente por clamd y clamscan en el siguiente reinicio. Esto se realizará siempre que la detección heurística de phishing esté activa. Esta base de datos incluye información de sitios web que pueden ser sitios de robo de credenciales («phishing») o posibles fuentes de programas maliciosos. Es obligatorio ejecutar freshclam al menos cada 30 minutos si se utiliza esta opción. Freshclam utiliza la infraestructura de réplicas de ClamAV para distribuir la base de datos y sus actualizaciones, pero todos los contenidos se ofrecen bajo los términos de uso de Google."
 
 #. Type: boolean
 #. Description
 #: ../clamav-freshclam.templates:10001
-#, fuzzy
-#| msgid "Do you want to load bytecode from the database?"
 msgid "Do you want to download the bytecode database?"
-msgstr "¿Desea cargar bytecodes de la base de datos?"
+msgstr "¿Desea descargar la base de datos de bytecodes?"
 
 #. Type: string
 #. Description
 #: ../clamav-freshclam.templates:11001
 msgid "Private mirror for freshclam:"
-msgstr ""
+msgstr "Réplica privada para freshclam:"
 
 #. Type: string
 #. Description
@@ -311,16 +329,14 @@ msgid ""
 "that fails, it tries to download the CVD file. This option overrides "
 "DatabaseMirror, DNSDatabaseInfo and ScriptedUpdates. It can be used multiple "
 "times to provide fall-back mirrors."
-msgstr ""
+msgstr "Esta opción le permite configurar de forma sencilla una réplica privada que freshclam utilizará. Si el valor «PrivateMirror» está configurado, freshclam no intentará utilizar el DNS para determinar si sus bases de datos están al día. En lugar de éste, utilizará la petición «If-Modified-Since» o comprobará directamente las cabeceras de los archivos de base de datos remotos. Freshclam intentará primero descargar el archivo CLD para cada base de datos. Si ésto falla, intentará descargar el archivo CVD. Esta opción toma precedencia sobre los valores «DatabaseMirror», «DNSDatabaseInfo» y «ScriptedUpdates». Puede definirse múltiples veces para definir réplicas alternativas en caso de fallo."
 
 #. Type: boolean
 #. Description
 #: ../clamav-freshclam.templates:12001 ../clamav-daemon.templates:22001
 #: ../clamav-milter.templates:32001
-#, fuzzy
-#| msgid "Do you want to enable mail scanning?"
 msgid "Do you want to enable log rotation?"
-msgstr "¿Desea activar el análisis del correo?"
+msgstr "¿Desea activar la rotación de logs?"
 
 #. Type: error
 #. Description
@@ -584,41 +600,38 @@ msgstr "¿Desea registrar información de la hora con cada mensaje?"
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:23001
-#, fuzzy
-#| msgid "Do you want to enable archive scanning?"
 msgid "Do you want to enable on-access scanning?"
-msgstr "¿Desea activar el análisis de archivos?"
+msgstr "¿Desea activar el análisis en el momento del acceso?"
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:24001
 msgid "Maximum file size to scan:"
-msgstr ""
+msgstr "Tamaño máximo de fichero a analizar:"
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:24001
-#, fuzzy
 msgid "A value of 0 disables the limit."
-msgstr "El valor 0 inhabilita el límite de tamaño."
+msgstr "El valor 0 deshabilita el límite."
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:25001
 msgid "Do you want to permit the use of the ALLMATCHSCAN command?"
-msgstr ""
+msgstr "¿Desea permitir el uso de la orden «ALLMATCHSCAN»?"
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:25001
 msgid "If set to no, clamd will reject any ALLMATCHSCAN command as invalid."
-msgstr ""
+msgstr "Clamd rechazará cualquier orden «ALLMATCHSCAN» como inválido si responde que no aquí."
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:26001
 msgid "Do you want memory or nested map scans to dump the content to disk?"
-msgstr ""
+msgstr "¿Desea que los análisis en memoria o anidados vuelquen los contenidos al disco?"
 
 #. Type: boolean
 #. Description
@@ -626,13 +639,13 @@ msgstr ""
 msgid ""
 "If you turn on this option, more data is written to disk and is available "
 "when the LeaveTemporaryFiles option is enabled."
-msgstr ""
+msgstr "Si activa esta opción se escribirán más datos en el disco. Estos datos estarán también disponibles cuando se habilite la opción «LeaveTemporaryFiles» (\"Dejar los ficheros temporales\", N. del T.)."
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:27001
 msgid "Do you want to completely turn off authenticode verification?"
-msgstr ""
+msgstr "¿Desea desactivar por completo la verificación authenticode?"
 
 #. Type: boolean
 #. Description
@@ -644,15 +657,13 @@ msgid ""
 "certificate in the chain validates against any trusted root, but does not "
 "match any revoked certificate, the file is marked as whitelisted. If the "
 "file does match a revoked certificate, the file is marked as virus."
-msgstr ""
+msgstr "Algunos archivos PE contienen firmas autenticode. Por omisión, la cadena de firmas en un archivo PE se compara con una base de datos de certificados conocidos y revocados si el archivo se está analizado y se ha marcado como virus. El archivo se marca como válido, introduciéndose en una lista blanca, si cualquiera de los certificados en la cadena son válidos con respecto a cualquier raíz válida, siempre que no coincida con ningún certificado revocado. Si el fichero coincide con un certificado revocado, se marca el fichero como virus."
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:28001
-#, fuzzy
-#| msgid "Do you want to enable mail scanning?"
 msgid "Do you want to enable scanning within SWF files?"
-msgstr "¿Desea activar el análisis del correo?"
+msgstr "¿Desea activar el análisis dentro de archivos SWF?"
 
 #. Type: boolean
 #. Description
@@ -660,15 +671,13 @@ msgstr "¿Desea activar el análisis del correo?"
 msgid ""
 "If you turn off this option, the original files will still be scanned, but "
 "without decoding and additional processing."
-msgstr ""
+msgstr "Si deshabilita esta opción se seguirá analizando los ficheros originales, pero sin decodificarlos ni hacer ningún tipo de procesado adicional."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:29001
-#, fuzzy
-#| msgid "Maximum size of the log file (MB):"
 msgid "Maximum size of a file to check for embedded PE:"
-msgstr "Límite de tamaño del fichero de registro de actividades (MB):"
+msgstr "Tamaño máximo de los ficheros en los que comprobar PE embebido:"
 
 #. Type: string
 #. Description
@@ -677,15 +686,13 @@ msgid ""
 "Files larger than this value will skip the additional analysis step. Note: "
 "disabling this limit or setting it too high may result in severe damage to "
 "the system."
-msgstr ""
+msgstr "Se saltará el paso adicional del análisis para los ficheros que superen este tamaño. Nota: si deshabilita el límite o lo fija en un valor muy elevado puede provocar daños graves en el sistema."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:30001
-#, fuzzy
-#| msgid "Maximum size of the log file (MB):"
 msgid "Maximum size of a HTML file to normalize:"
-msgstr "Límite de tamaño del fichero de registro de actividades (MB):"
+msgstr "Tamaño máximo de los archivos HTML a normalizar:"
 
 #. Type: string
 #. Description
@@ -694,15 +701,13 @@ msgid ""
 "HTML files larger than this value will not be normalized or scanned. Note: "
 "disabling this limit or setting it too high may result in severe damage to "
 "the system."
-msgstr ""
+msgstr "Los ficheros HTML cuyo tamaño supere este valor no serán normalizados ni analizados. Nota: si deshabilita el límite o lo fija en un valor muy elevado puede provocar daños graves en el sistema."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:31001
-#, fuzzy
-#| msgid "Maximum size of the log file (MB):"
 msgid "Maximum size of a normalized HTML file to scan:"
-msgstr "Límite de tamaño del fichero de registro de actividades (MB):"
+msgstr "Tamaño máximo del fichero HTML normalizado a analizar:"
 
 #. Type: string
 #. Description
@@ -711,15 +716,13 @@ msgid ""
 "HTML files larger than this value after normalization will not be scanned. "
 "Note: disabling this limit or setting it too high may result in severe "
 "damage to the system."
-msgstr ""
+msgstr "Los ficheros HTML cuyo tamaño supere este valor tras normalizarlos no serán analizados. Nota: si deshabilita el límite o lo fija en un valor muy elevado puede provocar daños graves en el sistema."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:32001
-#, fuzzy
-#| msgid "Maximum size of the log file (MB):"
 msgid "Maximum size of a script file to normalize:"
-msgstr "Límite de tamaño del fichero de registro de actividades (MB):"
+msgstr "Tamaño máximo del fichero de script a normalizar:"
 
 #. Type: string
 #. Description
@@ -728,13 +731,13 @@ msgid ""
 "Script content larger than this value will not be normalized or scanned. "
 "Note: disabling this limit or setting it too high may result in severe "
 "damage to the system."
-msgstr ""
+msgstr "Los ficheros script cuyo tamaño supere este valor no serán normalizados ni analizados. Nota: si deshabilita el límite o lo fija en un valor muy elevado puede provocar daños graves en el sistema."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:33001
 msgid "Maximum size of a ZIP file to reanalyze type recognition:"
-msgstr ""
+msgstr "Tamaño máximo de los archivos ZIP que se reanalizar para reconocer otros tipos:"
 
 #. Type: string
 #. Description
@@ -743,7 +746,7 @@ msgid ""
 "ZIP files larger than this value will skip the step to potentially reanalyze "
 "as PE. Note: disabling this limit or setting it too high may result in "
 "severe damage to the system."
-msgstr ""
+msgstr "Se omitirá el paso para reanalizar los ficheros ZIP como ficheros PE si su tamaño supera este valor. Nota: si deshabilita el límite o lo fija en un valor muy elevado puede provocar daños graves en el sistema."
 
 #. Type: string
 #. Description
@@ -864,16 +867,14 @@ msgstr "Intervalo de ejecución del bytecode en milisegundos:"
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:40001
-#, fuzzy
-#| msgid "Do you want to enable mail scanning?"
 msgid "Do you want to submit statistical information?"
-msgstr "¿Desea activar el análisis del correo?"
+msgstr "¿Desea enviar información estadística?"
 
 #. Type: boolean
 #. Description
 #: ../clamav-daemon.templates:41001
 msgid "Do you want to disable submitting files flagged as malware?"
-msgstr ""
+msgstr "¿Desea deshabilitar el envío de archivos que se han marcado como maliciosos?"
 
 #. Type: boolean
 #. Description
@@ -881,20 +882,20 @@ msgstr ""
 msgid ""
 "If this is enabled, individual PE sections of files flagged as malware will "
 "be submitted."
-msgstr ""
+msgstr "Si se habilita esta opción se enviarán las secciones PE de los ficheros que se hayan marcado como código malicioso."
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:42001
 msgid "HostID, a UUID to use when submitting statistical information:"
-msgstr ""
+msgstr "Hostid, el UUID a utilizar cuando se envíe información estadística:"
 
 #. Type: string
 #. Description
 #: ../clamav-daemon.templates:43001
 msgid ""
 "Time in seconds to wait for the stats server to come back with a response:"
-msgstr ""
+msgstr "Tiempo (en segundos) a esperar para que el servidor de estadísticas devuelva una respuesta:"
 
 #. Type: boolean
 #. Description
@@ -936,8 +937,8 @@ msgstr ""
 "Seleccione qué método debería usar clamav-milter para comunicarse con "
 "Sendmail. Se pueden usar los siguientes formatos:\n"
 " - Socket de dominio Unix: [[unix|local]:]/ruta/al/fichero.\n"
-" - Socket IPv4       : inet:port@[nombre-equipo|dirección-IP].\n"
-" - IPv6 socket       : inet6:port@[nombre-equipo|dirección-IP]."
+" - Socket IPv4       : inet:puerto@[nombre-equipo|dirección-IP].\n"
+" - IPv6 socket       : inet6:puerto@[nombre-equipo|dirección-IP]."
 
 #. Type: boolean
 #. Description
@@ -1411,7 +1412,7 @@ msgstr ""
 #. Description
 #: ../clamav-milter.templates:23001
 msgid "Maximum size of the log file (MB):"
-msgstr "Límite de tamaño del fichero de registro de actividades (MB):"
+msgstr "Máximo tamaño del fichero de registro de actividades (en MB):"
 
 #. Type: string
 #. Description
@@ -1568,7 +1569,7 @@ msgstr ""
 #. Description
 #: ../clamav-milter.templates:31001
 msgid "Do you want clamav-milter to support multiple recipients?"
-msgstr ""
+msgstr "¿Desea que clamav-milter soporte múltiples destinatarios?"
 
 #. Type: boolean
 #. Description
@@ -1582,7 +1583,7 @@ msgid ""
 "both cases only the last recipient is reported. If SupportMultipleRecipients "
 "is on: then one line is logged for each recipient and the command indicated "
 "by VirusAction is also executed once for each recipient."
-msgstr ""
+msgstr "Esta opción afecta al comportamiento de las opciones «LogInfected», «LogClean» y «VirusAction» cuando se analice un mensaje que tenga múltiples destinatarios. Si el valor de «SupportMultipleRecipients» está desactivado (valor «off») entonces sólo se generará una entrada en el registro de actividad por cada mensaje. Además, si se detecta que el mensaje es malicioso, sólo se ejecuta una vez la orden indicada en «VirusAction». En ambos casos sólo se envía un informe al último destinatario del mensaje. Si se habilita la opción «SupportMultipleRecipients» (valor: «on») entonces sólo se registra una línea por cada destinatario y la orden indicada en «VirusAction» se ejecuta también una sola vez por cada destinatario."
 
 #. Type: boolean
 #. Description
@@ -1590,11 +1591,10 @@ msgstr ""
 msgid ""
 "Note: although it's probably a good idea to enable this option, the default "
 "value is currently set to off for legacy reasons."
-msgstr ""
+msgstr "Nota: Aunque habitualmente sea una buena idea habilitar esta opción, por omisión se deshabilita por motivos históricos."
 
-#, fuzzy
 #~ msgid "Set to a value of '0' to disable the timeout."
-#~ msgstr "El valor 0 inhabilita el límite de tamaño."
+#~ msgstr "Si se define el valor a '0' se deshabilita el límite de tiempo."
 
 #~ msgid "Do you want to enable RAR archive scanning?"
 #~ msgstr "¿Quiere habilitar el análisis de archivos RAR?"
diff --git a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -62,7 +62,7 @@ CONFIG := CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLA
 	--with-dbdir=/var/lib/clamav --sysconfdir=/etc/clamav \
 	--disable-clamav --disable-unrar --enable-milter --enable-dns-fix \
 	--with-libjson \
-	--with-gnu-ld --with-system-tommath --without-included-ltdl $(SYSTEM_LLVM)
+	--with-gnu-ld $(SYSTEM_LLVM)
 
 DEBUG_OPTS=
 
diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides
--- a/debian/source/lintian-overrides
+++ b/debian/source/lintian-overrides
@@ -3,6 +3,6 @@ clamav source: wildcard-matches-nothing-in-dep5-copyright libclamav/mspack.c (pa
 clamav source: wildcard-matches-nothing-in-dep5-copyright libclamav/mspack.h (paragraph at line *)
 
 # These are false positives, because configure and aclocal.m4 exist.
-clamav source: unused-file-paragraph-in-dep5-copyright paragraph at line 612
-clamav source: unused-file-paragraph-in-dep5-copyright paragraph at line 621
+clamav source: unused-file-paragraph-in-dep5-copyright paragraph at line 605
+clamav source: unused-file-paragraph-in-dep5-copyright paragraph at line 614
 
diff --git a/docs/clamdoc.pdf b/docs/clamdoc.pdf
Binary files a/docs/clamdoc.pdf and b/docs/clamdoc.pdf differ
diff --git a/docs/clamdoc.tex b/docs/clamdoc.tex
--- a/docs/clamdoc.tex
+++ b/docs/clamdoc.tex
@@ -72,7 +72,7 @@
     \vspace{3cm}
     \begin{flushright}
 	\rule[-1ex]{8cm}{3pt}\\
-	\huge Clam AntiVirus 0.98.5\\
+	\huge Clam AntiVirus 0.98.6\\
 	\huge \emph{User Manual}\\
     \end{flushright}
 
diff --git a/docs/man/clamd.conf.5.in b/docs/man/clamd.conf.5.in
--- a/docs/man/clamd.conf.5.in
+++ b/docs/man/clamd.conf.5.in
@@ -319,7 +319,7 @@ Set bytecode execution mode.
 .br
 \fBForceJIT\fR \- always choose JIT, fail if not possible
 .br
-\fBForceIntepreter\fR \- always choose interpreter
+\fBForceInterpreter\fR \- always choose interpreter
 .br
 \fBTest\fR \- run with both JIT and interpreter and compare results. Make all failures fatal.
 .RE
diff --git a/docs/man/clamsubmit.1.in b/docs/man/clamsubmit.1.in
--- a/docs/man/clamsubmit.1.in
+++ b/docs/man/clamsubmit.1.in
@@ -1,4 +1,4 @@
-.TH "Config tool" "1" "March 20, 2014" "ClamAV @VERSION@" "Clam AntiVirus"
+.TH "File submission tool" "1" "March 20, 2014" "ClamAV @VERSION@" "Clam AntiVirus"
 .SH "NAME"
 .LP 
 clamsubmit \- File submission utility for ClamAV
@@ -26,8 +26,6 @@ Required option for setting the name of the sender for the submission.
 .TP
 \fB-p FILE\fR
 Submit a file that reports as a false positive (ClamAV flags the file as virus). FILE can be \- to specify stdin. Mutually exclusive with \-n.
-.SH "CREDITS"
-The idea of this tool is based on Postfix's postconf. clamconf was created under pressure from Tomasz Papszun ;-)
 .SH "AUTHOR"
 .LP 
 Shawn Webb <swebb@sourcefire.com>
diff --git a/docs/phishsigs_howto.pdf b/docs/phishsigs_howto.pdf
Binary files a/docs/phishsigs_howto.pdf and b/docs/phishsigs_howto.pdf differ
diff --git a/docs/signatures.pdf b/docs/signatures.pdf
Binary files a/docs/signatures.pdf and b/docs/signatures.pdf differ
diff --git a/freshclam/Makefile.am b/freshclam/Makefile.am
--- a/freshclam/Makefile.am
+++ b/freshclam/Makefile.am
@@ -51,7 +51,7 @@ freshclam_SOURCES = \
 
 AM_CFLAGS=@WERR_CFLAGS@
 DEFS = @DEFS@ -DCL_NOTHREADS
-AM_CPPFLAGS = @SSL_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @FRESHCLAM_CPPFLAGS@  @JSON_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @FRESHCLAM_CPPFLAGS@  @JSON_CPPFLAGS@
 LIBS = @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
 
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=freshclam$(EXEEXT)
diff --git a/freshclam/Makefile.in b/freshclam/Makefile.in
--- a/freshclam/Makefile.in
+++ b/freshclam/Makefile.in
@@ -472,7 +472,7 @@ freshclam_SOURCES = \
     mirman.h
 
 AM_CFLAGS = @WERR_CFLAGS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @FRESHCLAM_CPPFLAGS@  @JSON_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @FRESHCLAM_CPPFLAGS@  @JSON_CPPFLAGS@
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = freshclam$(EXEEXT)
 CLEANFILES = *.gcda *.gcno
 all: all-am
diff --git a/freshclam/freshclam.c b/freshclam/freshclam.c
--- a/freshclam/freshclam.c
+++ b/freshclam/freshclam.c
@@ -244,7 +244,7 @@ download (const struct optstruct *opts, const char *cfgfile)
                     opt = (struct optstruct *) opt->nextarg;
                     if (!opt)
                     {
-                        logg ("Update failed. Your network may be down or none of the mirrors listed in %s is working. Check http://www.clamav.net/documentation.html for possible reasons.\n", cfgfile);
+                        logg ("Update failed. Your network may be down or none of the mirrors listed in %s is working. Check http://www.clamav.net/doc/mirrors-faq.html for possible reasons.\n", cfgfile);
                     }
                 }
 
diff --git a/freshclam/manager.c b/freshclam/manager.c
--- a/freshclam/manager.c
+++ b/freshclam/manager.c
@@ -2060,7 +2060,7 @@ updatedb (const char *dbname, const char *hostname, char *ip, int *signo,
             logg ("^Current functionality level = %d, recommended = %d\n",
                   flevel, current->fl);
             logg ("Please check if ClamAV tools are linked against the proper version of libclamav\n");
-            logg ("DON'T PANIC! Read http://www.clamav.net/documentation.html\n";);
+            logg ("DON'T PANIC! Read http://www.clamav.net/doc/install.html\n";);
         }
 
         *signo += current->sigs;
diff --git a/libclamav/Makefile.am b/libclamav/Makefile.am
--- a/libclamav/Makefile.am
+++ b/libclamav/Makefile.am
@@ -149,30 +149,30 @@ libclamav_la_LDFLAGS += -Wl,@VERSIONSCRIPTFLAG@,@top_srcdir@/libclamav/libclamav
 endif
 
 if USE_INTERNAL_MSPACK
-SUBDIRS += libmspack-0.4alpha
-libclamav_la_CFLAGS += -I@top_srcdir@/libclamav/libmspack-0.4alpha/mspack
-libclamav_la_LIBADD +=  @top_builddir@/libclamav/libmspack-0.4alpha/.libs/cabc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/system.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/kwajd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/hlpc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/chmd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/qtmd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/litc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/oabc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/lzxd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/litd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/crc32.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/lzssd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/kwajc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/cabd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/szddd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/lzxc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/mszipd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/szddc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/oabd.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/chmc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/mszipc.o \
-			@top_builddir@/libclamav/libmspack-0.4alpha/.libs/hlpd.o
+SUBDIRS += libmspack-0.5alpha
+libclamav_la_CFLAGS += -I@top_srcdir@/libclamav/libmspack-0.5alpha/mspack
+libclamav_la_LIBADD +=  @top_builddir@/libclamav/libmspack-0.5alpha/.libs/cabc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/system.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/kwajd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/hlpc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/chmd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/qtmd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/litc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/oabc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/lzxd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/litd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/crc32.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/lzssd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/kwajc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/cabd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/szddd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/lzxc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/mszipd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/szddc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/oabd.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/chmc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/mszipc.o \
+			@top_builddir@/libclamav/libmspack-0.5alpha/.libs/hlpd.o
 else
 libclamav_la_CFLAGS += $(LIBMSPACK_CFLAGS)
 libclamav_la_LDFLAGS += $(LIBMSPACK_LIBS)
diff --git a/libclamav/bytecode_api.h b/libclamav/bytecode_api.h
--- a/libclamav/bytecode_api.h
+++ b/libclamav/bytecode_api.h
@@ -100,7 +100,9 @@ enum FunctionalityLevels {
     FUNC_LEVEL_098_1     = 76, /**< LibClamAV release 0.98.2 */ /*last syncing to clamav*/
     FUNC_LEVEL_098_2     = 77, /**< LibClamAV release 0.98.2 */
     FUNC_LEVEL_098_3     = 77, /**< LibClamAV release 0.98.3 */
-    FUNC_LEVEL_098_4     = 78, /**< LibClamAV release 0.98.4: JSON reading API requires this minimum level */
+    FUNC_LEVEL_098_4     = 77, /**< LibClamAV release 0.98.4 */
+    FUNC_LEVEL_098_5     = 79, /**< LibClamAV release 0.98.5: JSON reading API requires this minimum level */
+    FUNC_LEVEL_098_6     = 79, /**< LibClamAV release 0.98.6 */
     FUNC_LEVEL_100       = 100 /*future release candidate*/
 };
 
diff --git a/libclamav/crypto.c b/libclamav/crypto.c
--- a/libclamav/crypto.c
+++ b/libclamav/crypto.c
@@ -60,11 +60,22 @@
 #include "others.h"
 #include "libclamav/conv.h"
 #include "libclamav/str.h"
+#include "iowrap.h"
 
 #if defined(_WIN32)
 char * strptime(const char *buf, const char *fmt, struct tm *tm);
 #endif
 
+#if defined(_WIN32)
+#define EXCEPTION_PREAMBLE __try {
+#define EXCEPTION_POSTAMBLE } __except (filter_memcpy(GetExceptionCode(), GetExceptionInformation())) { \
+    winres=1; \
+}
+#else
+#define EXCEPTION_PREAMBLE
+#define EXCEPTION_POSTAMBLE
+#endif
+
 #if !defined(MIN)
     #define MIN(x,y) ((x)<(y)?(x):(y))
 #endif
@@ -132,6 +143,7 @@ unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned cha
     const EVP_MD *md;
     unsigned int i;
     size_t cur;
+    int winres=0;
 
     md = EVP_get_digestbyname(alg);
     if (!(md))
@@ -170,6 +182,8 @@ unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned cha
     cur=0;
     while (cur < len) {
         size_t todo = MIN((unsigned long)EVP_MD_block_size(md), (unsigned long)(len-cur));
+
+        EXCEPTION_PREAMBLE
         if (!EVP_DigestUpdate(ctx, (void *)(((unsigned char *)buf)+cur), todo)) {
             if (!(obuf))
                 free(ret);
@@ -180,6 +194,18 @@ unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned cha
             EVP_MD_CTX_destroy(ctx);
             return NULL;
         }
+        EXCEPTION_POSTAMBLE
+
+        if (winres) {
+            if (!(obuf))
+                free(ret);
+
+            if ((olen))
+                *olen = 0;
+
+            EVP_MD_CTX_destroy(ctx);
+            return NULL;
+        }
 
         cur += todo;
     }
@@ -240,6 +266,7 @@ unsigned char *cl_hash_file_fd_ctx(EVP_MD_CTX *ctx, int fd, unsigned int *olen)
     int mdsz;
     unsigned int hashlen;
     STATBUF sb;
+    int winres=0;
 
 	unsigned int blocksize;
 
@@ -277,12 +304,21 @@ unsigned char *cl_hash_file_fd_ctx(EVP_MD_CTX *ctx, int fd, unsigned int *olen)
 #else
     while ((nread = read(fd, buf, blocksize)) > 0) {
 #endif
+        EXCEPTION_PREAMBLE
         if (!EVP_DigestUpdate(ctx, buf, nread)) {
             free(buf);
             free(hash);
 
             return NULL;
         }
+        EXCEPTION_POSTAMBLE
+
+        if (winres) {
+            free(buf);
+            free(hash);
+
+            return NULL;
+        }
     }
 
     if (!EVP_DigestFinal_ex(ctx, hash, &hashlen)) {
@@ -1123,11 +1159,18 @@ void *cl_hash_init(const char *alg)
 
 int cl_update_hash(void *ctx, void *data, size_t sz)
 {
+    int winres=0;
+
     if (!(ctx) || !(data))
         return -1;
 
+    EXCEPTION_PREAMBLE
     if (!EVP_DigestUpdate((EVP_MD_CTX *)ctx, data, sz))
         return -1;
+    EXCEPTION_POSTAMBLE
+
+    if (winres)
+        return -1;
 
     return 0;
 }
diff --git a/libclamav/cvd.c b/libclamav/cvd.c
--- a/libclamav/cvd.c
+++ b/libclamav/cvd.c
@@ -660,7 +660,7 @@ int cli_cvdload(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigne
     if(cvd.fl > cl_retflevel()) {
 	cli_warnmsg("***********************************************************\n");
 	cli_warnmsg("***  This version of the ClamAV engine is outdated.     ***\n");
-	cli_warnmsg("***   Read http://www.clamav.net/documentation.html     ***\n");
+	cli_warnmsg("***   Read http://www.clamav.net/doc/install.html       ***\n");
 	cli_warnmsg("***********************************************************\n");
     }
 
diff --git a/libclamav/filetypes.c b/libclamav/filetypes.c
--- a/libclamav/filetypes.c
+++ b/libclamav/filetypes.c
@@ -41,6 +41,7 @@
 #include "iowrap.h"
 #include "mbr.h"
 #include "gpt.h"
+#include "ooxml.h"
 
 #include "htmlnorm.h"
 #include "entconv.h"
diff --git a/libclamav/iowrap.c b/libclamav/iowrap.c
--- a/libclamav/iowrap.c
+++ b/libclamav/iowrap.c
@@ -33,7 +33,7 @@
 #endif
 
 #ifdef _WIN32
-static int filter_memcpy(unsigned int code, struct _EXCEPTION_POINTERS *ep) {
+int filter_memcpy(unsigned int code, struct _EXCEPTION_POINTERS *ep) {
     if ((code == EXCEPTION_IN_PAGE_ERROR) || (code == STATUS_DEVICE_DATA_ERROR)) {
         return EXCEPTION_EXECUTE_HANDLER;
     }
diff --git a/libclamav/iowrap.h b/libclamav/iowrap.h
--- a/libclamav/iowrap.h
+++ b/libclamav/iowrap.h
@@ -42,4 +42,8 @@
  */
 int cli_memcpy(void *target, const void *source, unsigned long size);
 
+#ifdef _WIN32
+int filter_memcpy(unsigned int code, struct _EXCEPTION_POINTERS *ep);
+#endif
+
 #endif
diff --git a/libclamav/jsparse/js-norm.c b/libclamav/jsparse/js-norm.c
--- a/libclamav/jsparse/js-norm.c
+++ b/libclamav/jsparse/js-norm.c
@@ -1112,7 +1112,7 @@ void cli_js_process_buffer(struct parser_state *state, const char *buf, size_t n
 				TOKEN_SET(&val, scope, state->current);
 				break;
 			case TOK_StringLiteral:
-				if(state->tokens.cnt > 0 && state->tokens.data[state->tokens.cnt-1].type == TOK_PLUS) {
+				if(state->tokens.cnt > 1 && state->tokens.data[state->tokens.cnt-1].type == TOK_PLUS) {
 					/* see if can fold */
 					yystype *prev_string = &state->tokens.data[state->tokens.cnt-2];
 					if(prev_string->type == TOK_StringLiteral) {
diff --git a/libclamav/libmspack-0.4alpha/NEWS b/libclamav/libmspack-0.4alpha/NEWS
deleted file mode 100644
--- a/libclamav/libmspack-0.4alpha/NEWS
+++ /dev/null
@@ -1 +0,0 @@
- 
diff --git a/libclamav/libmspack-0.4alpha/AUTHORS b/libclamav/libmspack-0.5alpha/AUTHORS
similarity index 100%
rename from libclamav/libmspack-0.4alpha/AUTHORS
rename to libclamav/libmspack-0.5alpha/AUTHORS
diff --git a/libclamav/libmspack-0.4alpha/COPYING.LIB b/libclamav/libmspack-0.5alpha/COPYING.LIB
similarity index 100%
rename from libclamav/libmspack-0.4alpha/COPYING.LIB
rename to libclamav/libmspack-0.5alpha/COPYING.LIB
diff --git a/libclamav/libmspack-0.4alpha/ChangeLog b/libclamav/libmspack-0.5alpha/ChangeLog
similarity index 88%
rename from libclamav/libmspack-0.4alpha/ChangeLog
rename to libclamav/libmspack-0.5alpha/ChangeLog
--- a/libclamav/libmspack-0.4alpha/ChangeLog
+++ b/libclamav/libmspack-0.5alpha/ChangeLog
@@ -1,3 +1,61 @@
+2015-01-18  Stuart Caie <kyzer@4u.net>
+
+	* lzxd_decompress(): the byte-alignment code for reading uncompressed
+	block headers presumed it could wind i_ptr back 2 bytes, but this
+	hasn't been true since READ_BYTES was allowed to read bytes straddling
+	two blocks, leaving just 1 byte in the read buffer. Thanks to Jakub
+	Wilk for finding the issue and providing a sample file.
+
+	* inflate(): off-by-one error. Distance codes are 0-29, not 0-30.
+	Thanks to Jakub Wilk again.
+
+	* chmd_read_headers(), search_chunk(): another fix for checking pointer
+	is within a chunk, thanks again to Jakub Wilk.
+
+2015-01-17  Stuart Caie <kyzer@4u.net>
+
+	* GET_UTF8_CHAR(): Remove 5/6-byte encoding support and check decoded
+	chars are no more than U+10FFFF.
+
+	* chmd_init_decomp(): A reset interval of 0 is invalid. Thanks to
+	Jakub Wilk for finding the issue and providing a sample and patch.
+
+2015-01-15  Stuart Caie <kyzer@4u.net>
+
+	* chmd_read_headers(): add a bounds check to prevent over-reading data,
+	which caused a segfault on 32-bit architectures. Thanks to Jakub Wilk.
+
+	* search_chunk(): change the order of pointer arithmetic operations to
+	avoid overflow during bounds checks, which lead to segfaults on 32-bit
+	architectures. Again, thanks to Jakub Wilk for finding this issue,
+	providing sample files and a patch.
+
+2015-01-08  Stuart Caie <kyzer@4u.net>
+
+	* cabd_extract(): No longer uses broken state data if extracting from
+	folder 1, 2, 1 and setting up folder 2 fails. This prevents a jump to
+	null and thus segfault. Thanks to Jakub Wilk again.
+
+	* cabd_read_string: reject empty strings. They are not found in any
+	valid CAB files. Thanks to Hanno B�for sending me an example.
+
+2015-01-05  Stuart Caie <kyzer@4u.net>
+
+	* cabd_can_merge_folders(): disallow folder merging if the combined
+	folder would have more than 65535 data blocks.
+
+	* cabd_decompress(): disallow files if their offset, length or
+	offset+length is more than 65535*32768, the maximum size of any
+	folder. Thanks to Jakub Wilk for identifying the problem and providing
+	a sample file.
+
+2014-04-20  Stuart Caie <kyzer@4u.net>
+
+	* readhuff.h: fixed the table overflow check, which allowed one more
+	code after capacity had been reached, resulting in a read of
+	uninitialized data inside the decoding table. Thanks to Denis Kroshin
+	for identifying the problem and providing a sample file.
+
 2013-05-27  Stuart Caie <kyzer@4u.net>
 
 	* test/oabx.c: added new example command for unpacking OAB files.
diff --git a/libclamav/libmspack-0.4alpha/INSTALL b/libclamav/libmspack-0.5alpha/INSTALL
similarity index 97%
rename from libclamav/libmspack-0.4alpha/INSTALL
rename to libclamav/libmspack-0.5alpha/INSTALL
--- a/libclamav/libmspack-0.4alpha/INSTALL
+++ b/libclamav/libmspack-0.5alpha/INSTALL
@@ -1,7 +1,7 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
 Inc.
 
    Copying and distribution of this file, with or without modification,
@@ -12,8 +12,8 @@ without warranty of any kind.
 Basic Installation
 ==================
 
-   Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
+   Briefly, the shell command `./configure && make && make install'
+should configure, build, and install this package.  The following
 more-detailed instructions are generic; see the `README' file for
 instructions specific to this package.  Some packages provide this
 `INSTALL' file but do not implement all of the features documented
@@ -309,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is
 overridden in the site shell script).
 
 Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
+an Autoconf limitation.  Until the limitation is lifted, you can use
+this workaround:
 
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+     CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
 
 `configure' Invocation
 ======================
@@ -367,4 +368,3 @@ operates.
 
 `configure' also accepts some other, not widely useful, options.  Run
 `configure --help' for more details.
-
diff --git a/libclamav/libmspack-0.4alpha/Makefile.am b/libclamav/libmspack-0.5alpha/Makefile.am
similarity index 97%
rename from libclamav/libmspack-0.4alpha/Makefile.am
rename to libclamav/libmspack-0.5alpha/Makefile.am
--- a/libclamav/libmspack-0.4alpha/Makefile.am
+++ b/libclamav/libmspack-0.5alpha/Makefile.am
@@ -12,7 +12,7 @@ if DEBUG
 AM_CFLAGS +=		-DDEBUG
 endif
 if GCC
-AM_CFLAGS +=		-Wall -W -Wno-unused
+AM_CFLAGS +=		-Wall -Wextra -Wno-unused-parameter -Wno-unused-result
 endif
 AM_CPPFLAGS =		-I$(top_srcdir)/mspack -I$(top_srcdir)/test 
 
diff --git a/libclamav/libmspack-0.5alpha/NEWS b/libclamav/libmspack-0.5alpha/NEWS
new file mode 100644
diff --git a/libclamav/libmspack-0.4alpha/README b/libclamav/libmspack-0.5alpha/README
similarity index 99%
rename from libclamav/libmspack-0.4alpha/README
rename to libclamav/libmspack-0.5alpha/README
--- a/libclamav/libmspack-0.4alpha/README
+++ b/libclamav/libmspack-0.5alpha/README
@@ -1,4 +1,4 @@
-libmspack 0.4alpha
+libmspack 0.5alpha
 
 The purpose of libmspack is to provide compressors and decompressors,
 archivers and dearchivers for Microsoft compression formats: CAB, CHM, WIM,
diff --git a/libclamav/libmspack-0.4alpha/TODO b/libclamav/libmspack-0.5alpha/TODO
similarity index 100%
rename from libclamav/libmspack-0.4alpha/TODO
rename to libclamav/libmspack-0.5alpha/TODO
diff --git a/libclamav/libmspack-0.4alpha/config.h.in b/libclamav/libmspack-0.5alpha/config.h.in
similarity index 95%
rename from libclamav/libmspack-0.4alpha/config.h.in
rename to libclamav/libmspack-0.5alpha/config.h.in
--- a/libclamav/libmspack-0.4alpha/config.h.in
+++ b/libclamav/libmspack-0.5alpha/config.h.in
@@ -85,6 +85,11 @@
 /* Version number of package */
 #undef VERSION
 
+/* Enable large inode numbers on Mac OS X 10.5.  */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 
diff --git a/libclamav/libmspack-0.4alpha/configure.ac b/libclamav/libmspack-0.5alpha/configure.ac
similarity index 96%
rename from libclamav/libmspack-0.4alpha/configure.ac
rename to libclamav/libmspack-0.5alpha/configure.ac
--- a/libclamav/libmspack-0.4alpha/configure.ac
+++ b/libclamav/libmspack-0.5alpha/configure.ac
@@ -1,7 +1,7 @@
 # -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.59)
-AC_INIT([libmspack],[0.4alpha],[kyzer@4u.net])
+AC_INIT([libmspack],[0.5alpha],[kyzer@4u.net])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([mspack/mspack.h])
diff --git a/libclamav/libmspack-0.4alpha/ltmain.sh b/libclamav/libmspack-0.5alpha/ltmain.sh
similarity index 99%
rename from libclamav/libmspack-0.4alpha/ltmain.sh
rename to libclamav/libmspack-0.5alpha/ltmain.sh
--- a/libclamav/libmspack-0.4alpha/ltmain.sh
+++ b/libclamav/libmspack-0.5alpha/ltmain.sh
@@ -70,7 +70,7 @@
 #         compiler:		$LTCC
 #         compiler flags:		$LTCFLAGS
 #         linker:		$LD (gnu? $with_gnu_ld)
-#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
+#         $progname:	(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1
 #         automake:	$automake_version
 #         autoconf:	$autoconf_version
 #
@@ -80,7 +80,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1ubuntu1"
+VERSION="2.4.2 Debian-2.4.2-1.7ubuntu1"
 TIMESTAMP=""
 package_revision=1.3337
 
diff --git a/libclamav/libmspack-0.4alpha/m4/ltoptions.m4 b/libclamav/libmspack-0.5alpha/m4/ltoptions.m4
similarity index 100%
rename from libclamav/libmspack-0.4alpha/m4/ltoptions.m4
rename to libclamav/libmspack-0.5alpha/m4/ltoptions.m4
diff --git a/libclamav/libmspack-0.4alpha/m4/ltsugar.m4 b/libclamav/libmspack-0.5alpha/m4/ltsugar.m4
similarity index 100%
rename from libclamav/libmspack-0.4alpha/m4/ltsugar.m4
rename to libclamav/libmspack-0.5alpha/m4/ltsugar.m4
diff --git a/libclamav/libmspack-0.4alpha/m4/ltversion.m4 b/libclamav/libmspack-0.5alpha/m4/ltversion.m4
similarity index 100%
rename from libclamav/libmspack-0.4alpha/m4/ltversion.m4
rename to libclamav/libmspack-0.5alpha/m4/ltversion.m4
diff --git a/libclamav/libmspack-0.4alpha/m4/lt~obsolete.m4 b/libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4
similarity index 100%
rename from libclamav/libmspack-0.4alpha/m4/lt~obsolete.m4
rename to libclamav/libmspack-0.5alpha/m4/lt~obsolete.m4
diff --git a/libclamav/libmspack-0.4alpha/mspack/cab.h b/libclamav/libmspack-0.5alpha/mspack/cab.h
similarity index 93%
rename from libclamav/libmspack-0.4alpha/mspack/cab.h
rename to libclamav/libmspack-0.5alpha/mspack/cab.h
--- a/libclamav/libmspack-0.4alpha/mspack/cab.h
+++ b/libclamav/libmspack-0.5alpha/mspack/cab.h
@@ -70,6 +70,13 @@
 #define CAB_BLOCKMAX (32768)
 #define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
 
+/* There are no more than 65535 data blocks per folder, so a folder cannot
+ * be more than 32768*65535 bytes in length. As files cannot span more than
+ * one folder, this is also their max offset, length and offset+length limit.
+ */
+#define CAB_FOLDERMAX (65535)
+#define CAB_LENGTHMAX (CAB_BLOCKMAX * CAB_FOLDERMAX)
+
 /* CAB compression definitions */
 
 struct mscab_compressor_p {
diff --git a/libclamav/libmspack-0.4alpha/mspack/cabc.c b/libclamav/libmspack-0.5alpha/mspack/cabc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/cabc.c
rename to libclamav/libmspack-0.5alpha/mspack/cabc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/cabd.c b/libclamav/libmspack-0.5alpha/mspack/cabd.c
similarity index 97%
rename from libclamav/libmspack-0.4alpha/mspack/cabd.c
rename to libclamav/libmspack-0.5alpha/mspack/cabd.c
--- a/libclamav/libmspack-0.4alpha/mspack/cabd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/cabd.c
@@ -74,8 +74,7 @@ static int cabd_read_headers(
   struct mspack_system *sys, struct mspack_file *fh,
   struct mscabd_cabinet_p *cab, off_t offset, int quiet);
 static char *cabd_read_string(
-  struct mspack_system *sys, struct mspack_file *fh,
-  struct mscabd_cabinet_p *cab, int *error);
+  struct mspack_system *sys, struct mspack_file *fh, int *error);
 
 static struct mscabd_cabinet *cabd_search(
   struct mscab_decompressor *base, const char *filename);
@@ -171,9 +170,9 @@ void mspack_destroy_cab_decompressor(struct mscab_decompressor *base) {
   struct mscab_decompressor_p *self = (struct mscab_decompressor_p *) base;
   if (self) {
     struct mspack_system *sys = self->system;
-    cabd_free_decomp(self);
     if (self->d) {
       if (self->d->infh) sys->close(self->d->infh);
+      cabd_free_decomp(self);
       sys->free(self->d);
     }
     sys->free(self);
@@ -391,14 +390,14 @@ static int cabd_read_headers(struct mspack_system *sys,
 
   /* read name and info of preceeding cabinet in set, if present */
   if (cab->base.flags & cfheadPREV_CABINET) {
-    cab->base.prevname = cabd_read_string(sys, fh, cab, &x); if (x) return x;
-    cab->base.previnfo = cabd_read_string(sys, fh, cab, &x); if (x) return x;
+    cab->base.prevname = cabd_read_string(sys, fh, &x); if (x) return x;
+    cab->base.previnfo = cabd_read_string(sys, fh, &x); if (x) return x;
   }
 
   /* read name and info of next cabinet in set, if present */
   if (cab->base.flags & cfheadNEXT_CABINET) {
-    cab->base.nextname = cabd_read_string(sys, fh, cab, &x); if (x) return x;
-    cab->base.nextinfo = cabd_read_string(sys, fh, cab, &x); if (x) return x;
+    cab->base.nextname = cabd_read_string(sys, fh, &x); if (x) return x;
+    cab->base.nextinfo = cabd_read_string(sys, fh, &x); if (x) return x;
   }
 
   /* read folders */
@@ -502,7 +501,7 @@ static int cabd_read_headers(struct mspack_system *sys,
     file->date_y = (x >> 9) + 1980;
 
     /* get filename */
-    file->filename = cabd_read_string(sys, fh, cab, &x);
+    file->filename = cabd_read_string(sys, fh, &x);
     if (x) { 
       sys->free(file);
       return x;
@@ -518,8 +517,7 @@ static int cabd_read_headers(struct mspack_system *sys,
 }
 
 static char *cabd_read_string(struct mspack_system *sys,
-			      struct mspack_file *fh,
-			      struct mscabd_cabinet_p *cab, int *error)
+			      struct mspack_file *fh, int *error)
 {
   off_t base = sys->tell(fh);
   char buf[256], *str;
@@ -528,8 +526,8 @@ static char *cabd_read_string(struct mspack_system *sys,
   /* read up to 256 bytes */
   len = sys->read(fh, &buf[0], 256);
 
-  /* search for a null terminator in the buffer */
-  for (i = 0, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; }
+  /* search for a null terminator in the buffer. reject empty strings */
+  for (i = 1, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; }
   if (!ok) {
     *error = MSPACK_ERR_DATAFORMAT;
     return NULL;
@@ -939,6 +937,12 @@ static int cabd_can_merge_folders(struct mspack_system *sys,
         return 0;
     }
 
+    /* check there are not too many data blocks after merging */
+    if ((lfol->base.num_blocks + rfol->base.num_blocks) > CAB_FOLDERMAX) {
+        D(("folder merge: too many data blocks in merged folders"))
+        return 0;
+    }
+
     if (!(lfi = lfol->merge_next) || !(rfi = rfol->merge_prev)) {
         D(("folder merge: one cabinet has no files to merge"))
         return 0;
@@ -991,6 +995,13 @@ static int cabd_extract(struct mscab_decompressor *base,
   sys = self->system;
   fol = (struct mscabd_folder_p *) file->folder;
 
+  /* validate the file's offset and length */
+  if ( (file->offset > CAB_LENGTHMAX) || (file->length > CAB_LENGTHMAX) ||
+      ((file->offset + file->length) > CAB_LENGTHMAX))
+  {
+    return self->error = MSPACK_ERR_DATAFORMAT;
+  }
+
   /* check if file can be extracted */
   if ((!fol) || (fol->merge_prev) ||
       (((file->offset + file->length) / CAB_BLOCKMAX) > fol->base.num_blocks))
@@ -1015,7 +1026,12 @@ static int cabd_extract(struct mscab_decompressor *base,
   }
 
   /* do we need to change folder or reset the current folder? */
-  if ((self->d->folder != fol) || (self->d->offset > file->offset)) {
+  if ((self->d->folder != fol) || (self->d->offset > file->offset) ||
+      !self->d->state)
+  {
+    /* free any existing decompressor */
+    cabd_free_decomp(self);
+
     /* do we need to open a new cab file? */
     if (!self->d->infh || (fol->data.cab != self->d->incab)) {
       /* close previous file handle if from a different cab */
@@ -1099,9 +1115,6 @@ static int cabd_init_decomp(struct mscab_decompressor_p *self, unsigned int ct)
 
   assert(self && self->d);
 
-  /* free any existing decompressor */
-  cabd_free_decomp(self);
-
   self->d->comp_type = ct;
 
   switch (ct & cffoldCOMPTYPE_MASK) {
@@ -1133,7 +1146,7 @@ static int cabd_init_decomp(struct mscab_decompressor_p *self, unsigned int ct)
 }
 
 static void cabd_free_decomp(struct mscab_decompressor_p *self) {
-  if (!self || !self->d || !self->d->folder || !self->d->state) return;
+  if (!self || !self->d || !self->d->state) return;
 
   switch (self->d->comp_type & cffoldCOMPTYPE_MASK) {
   case cffoldCOMPTYPE_NONE:    noned_free((struct noned_state *) self->d->state);   break;
@@ -1264,7 +1277,8 @@ static int cabd_sys_read_block(struct mspack_system *sys,
     /* blocks must not be over CAB_INPUTMAX in size */
     len = EndGetI16(&hdr[cfdata_CompressedSize]);
     if (((d->i_end - d->i_ptr) + len) > CAB_INPUTMAX) {
-      D(("block size > CAB_INPUTMAX (%ld + %d)", d->i_end - d->i_ptr, len))
+      D(("block size > CAB_INPUTMAX (%ld + %d)",
+          (long)(d->i_end - d->i_ptr), len))
       return MSPACK_ERR_DATAFORMAT;
     }
 
diff --git a/libclamav/libmspack-0.4alpha/mspack/chm.h b/libclamav/libmspack-0.5alpha/mspack/chm.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/chm.h
rename to libclamav/libmspack-0.5alpha/mspack/chm.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/chmc.c b/libclamav/libmspack-0.5alpha/mspack/chmc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/chmc.c
rename to libclamav/libmspack-0.5alpha/mspack/chmc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/chmd.c b/libclamav/libmspack-0.5alpha/mspack/chmd.c
similarity index 97%
rename from libclamav/libmspack-0.4alpha/mspack/chmd.c
rename to libclamav/libmspack-0.5alpha/mspack/chmd.c
--- a/libclamav/libmspack-0.4alpha/mspack/chmd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/chmd.c
@@ -254,7 +254,7 @@ static const unsigned char guids[32] = {
 #define READ_ENCINT(var) do {			\
     (var) = 0;					\
     do {					\
-	if (p > end) goto chunk_end;		\
+	if (p >= end) goto chunk_end;		\
 	(var) = ((var) << 7) | (*p & 0x7F);	\
     } while (*p++ & 0x80);			\
 } while (0)
@@ -266,7 +266,7 @@ static int chmd_read_headers(struct mspack_system *sys, struct mspack_file *fh,
   unsigned char buf[0x54], *chunk = NULL, *name, *p, *end;
   struct mschmd_file *fi, *link = NULL;
   off_t offset, length;
-  int num_entries, i;
+  int num_entries;
 
   /* initialise pointers */
   chm->files         = NULL;
@@ -446,7 +446,7 @@ static int chmd_read_headers(struct mspack_system *sys, struct mspack_file *fh,
 
     while (num_entries--) {
       READ_ENCINT(name_len);
-      if (name_len > end - p) goto chunk_end;
+      if (name_len > (unsigned int) (end - p)) goto chunk_end;
       name = p; p += name_len;
       READ_ENCINT(section);
       READ_ENCINT(offset);
@@ -688,7 +688,7 @@ static int search_chunk(struct mschmd_header *chm,
 {
     const unsigned char *start, *end, *p;
     unsigned int qr_size, num_entries, qr_entries, qr_density, name_len;
-    unsigned int L, R, M, sec, fname_len, entries_off, is_pmgl;
+    unsigned int L, R, M, fname_len, entries_off, is_pmgl;
     int cmp;
 
     fname_len = strlen(filename);
@@ -748,7 +748,7 @@ static int search_chunk(struct mschmd_header *chm,
 	    /* compare filename with entry QR points to */
 	    p = &chunk[entries_off + (M ? EndGetI16(start - (M << 1)) : 0)];
 	    READ_ENCINT(name_len);
-	    if (name_len > end - p) goto chunk_end;
+	    if (name_len > (unsigned int) (end - p)) goto chunk_end;
 	    cmp = compare(filename, (char *)p, fname_len, name_len);
 
 	    if (cmp == 0) break;
@@ -785,7 +785,7 @@ static int search_chunk(struct mschmd_header *chm,
     *result = NULL;
     while (num_entries-- > 0) {
 	READ_ENCINT(name_len);
-	if (name_len > end - p) goto chunk_end;
+	if (name_len > (unsigned int) (end - p)) goto chunk_end;
 	cmp = compare(filename, (char *)p, fname_len, name_len);
 	p += name_len;
 
@@ -852,35 +852,27 @@ static const unsigned char mspack_tolower_map[256] = {
 };
 #endif
 
-/* decodes a UTF-8 character from s[] into c. Will not read past e. */
+/* decodes a UTF-8 character from s[] into c. Will not read past e. 
+ * doesn't test that extension bytes are %10xxxxxx.
+ * allows some overlong encodings.
+ */
 #define GET_UTF8_CHAR(s, e, c) do {					\
     unsigned char x = *s++;						\
     if (x < 0x80) c = x;						\
-    else if (x < 0xC0) c = -1;						\
-    else if (x < 0xE0) {						\
-	c = (s >= e) ? -1 : ((x & 0x1F) << 6) | (*s++ & 0x3F);		\
+    else if (x >= 0xC2 && x < 0xE0 && s < e) {				\
+	c = (x & 0x1F) << 6 | (*s++ & 0x3F);				\
     }									\
-    else if (x < 0xF0) {						\
-        c = (s+2 > e) ? -1 : ((x & 0x0F) << 12)	| ((s[0] & 0x3F) <<  6)	\
-	    | (s[1] & 0x3F);						\
+    else if (x >= 0xE0 && x < 0xF0 && s+1 < e) {			\
+	c = (x & 0x0F) << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F);	\
 	s += 2;								\
     }									\
-    else if (x < 0xF8) {						\
-	c = (s+3 > e) ? -1 : ((x & 0x07) << 18) | ((s[0] & 0x3F) << 12) \
-	    | ((s[1] & 0x3F) << 6) | (s[2] & 0x3F);			\
+    else if (x >= 0xF0 && x <= 0xF5 && s+2 < e) {			\
+	c = (x & 0x07) << 18 | (s[0] & 0x3F) << 12 |			\
+	    (s[1] & 0x3F) << 6 | (s[2] & 0x3F);				\
+	if (c > 0x10FFFF) c = 0xFFFD;					\
 	s += 3;								\
     }									\
-    else if (x < 0xFC) {						\
-	c = (s+4 > e) ? -1 : ((x & 0x03) << 24) | ((s[0] & 0x3F) << 18) \
-	    | ((s[1] & 0x3F) << 12)|((s[2] & 0x3F) << 6)|(s[3] & 0x3F);	\
-	s += 4;								\
-    }									\
-    else if (x < 0xFE) {						\
-        c = (s+5>e)?-1:((x&1)<<30)|((s[0]&0x3F)<<24)|((s[1]&0x3F)<<18)| \
-	    ((s[2] & 0x3F) << 12) | ((s[3] & 0x3F) << 6)|(s[4] & 0x3F);	\
-	s += 5;								\
-    }									\
-    else c = -1;							\
+    else c = 0xFFFD;							\
 } while (0)
 
 /* case-insensitively compares two UTF8 encoded strings. String length for
@@ -1125,7 +1117,7 @@ static int chmd_init_decomp(struct mschm_decompressor_p *self,
   }
 
   /* validate reset_interval */
-  if (reset_interval % LZX_FRAME_SIZE || !reset_interval) {
+  if (reset_interval == 0 || reset_interval % LZX_FRAME_SIZE) {
     D(("bad controldata reset interval"))
     return self->error = MSPACK_ERR_DATAFORMAT;
   }
diff --git a/libclamav/libmspack-0.4alpha/mspack/crc32.c b/libclamav/libmspack-0.5alpha/mspack/crc32.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/crc32.c
rename to libclamav/libmspack-0.5alpha/mspack/crc32.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/crc32.h b/libclamav/libmspack-0.5alpha/mspack/crc32.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/crc32.h
rename to libclamav/libmspack-0.5alpha/mspack/crc32.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/des.h b/libclamav/libmspack-0.5alpha/mspack/des.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/des.h
rename to libclamav/libmspack-0.5alpha/mspack/des.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/hlp.h b/libclamav/libmspack-0.5alpha/mspack/hlp.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/hlp.h
rename to libclamav/libmspack-0.5alpha/mspack/hlp.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/hlpc.c b/libclamav/libmspack-0.5alpha/mspack/hlpc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/hlpc.c
rename to libclamav/libmspack-0.5alpha/mspack/hlpc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/hlpd.c b/libclamav/libmspack-0.5alpha/mspack/hlpd.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/hlpd.c
rename to libclamav/libmspack-0.5alpha/mspack/hlpd.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/kwaj.h b/libclamav/libmspack-0.5alpha/mspack/kwaj.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/kwaj.h
rename to libclamav/libmspack-0.5alpha/mspack/kwaj.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/kwajc.c b/libclamav/libmspack-0.5alpha/mspack/kwajc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/kwajc.c
rename to libclamav/libmspack-0.5alpha/mspack/kwajc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/kwajd.c b/libclamav/libmspack-0.5alpha/mspack/kwajd.c
similarity index 97%
rename from libclamav/libmspack-0.4alpha/mspack/kwajd.c
rename to libclamav/libmspack-0.5alpha/mspack/kwajd.c
--- a/libclamav/libmspack-0.4alpha/mspack/kwajd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/kwajd.c
@@ -41,7 +41,7 @@ static void lzh_free(
 static int lzh_read_lens(
     struct kwajd_stream *kwaj,
     unsigned int type, unsigned int numsyms,
-    unsigned char *lens, unsigned short *table);
+    unsigned char *lens);
 static int lzh_read_input(
     struct kwajd_stream *kwaj);
 
@@ -399,14 +399,13 @@ static int kwajd_error(struct mskwaj_decompressor *base)
 	return MSPACK_ERR_OK;				\
 } while (0)
 
-#define BUILD_TREE(tbl, type)					\
-    STORE_BITS;							\
-    err = lzh_read_lens(lzh, type, MAXSYMBOLS(tbl),		\
-			 &HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0));	\
-    if (err) return err;					\
-    RESTORE_BITS;						\
-    if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl),	\
-	&HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0)))			\
+#define BUILD_TREE(tbl, type)						\
+    STORE_BITS;								\
+    err = lzh_read_lens(lzh, type, MAXSYMBOLS(tbl), &HUFF_LEN(tbl,0));	\
+    if (err) return err;						\
+    RESTORE_BITS;							\
+    if (make_decode_table(MAXSYMBOLS(tbl), TABLEBITS(tbl),		\
+	&HUFF_LEN(tbl,0), &HUFF_TABLE(tbl,0)))				\
 	return MSPACK_ERR_DATAFORMAT;
 
 #define WRITE_BYTE do {							\
@@ -494,7 +493,7 @@ static void lzh_free(struct kwajd_stream *lzh)
 
 static int lzh_read_lens(struct kwajd_stream *lzh,
 			 unsigned int type, unsigned int numsyms,
-			 unsigned char *lens, unsigned short *table)
+			 unsigned char *lens)
 {
     register unsigned int bit_buffer;
     register int bits_left;
diff --git a/libclamav/libmspack-0.4alpha/mspack/lit.h b/libclamav/libmspack-0.5alpha/mspack/lit.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/lit.h
rename to libclamav/libmspack-0.5alpha/mspack/lit.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/litc.c b/libclamav/libmspack-0.5alpha/mspack/litc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/litc.c
rename to libclamav/libmspack-0.5alpha/mspack/litc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/litd.c b/libclamav/libmspack-0.5alpha/mspack/litd.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/litd.c
rename to libclamav/libmspack-0.5alpha/mspack/litd.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/lzss.h b/libclamav/libmspack-0.5alpha/mspack/lzss.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/lzss.h
rename to libclamav/libmspack-0.5alpha/mspack/lzss.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/lzssd.c b/libclamav/libmspack-0.5alpha/mspack/lzssd.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/lzssd.c
rename to libclamav/libmspack-0.5alpha/mspack/lzssd.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/lzx.h b/libclamav/libmspack-0.5alpha/mspack/lzx.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/lzx.h
rename to libclamav/libmspack-0.5alpha/mspack/lzx.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/lzxc.c b/libclamav/libmspack-0.5alpha/mspack/lzxc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/lzxc.c
rename to libclamav/libmspack-0.5alpha/mspack/lzxc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/lzxd.c b/libclamav/libmspack-0.5alpha/mspack/lzxd.c
similarity index 99%
rename from libclamav/libmspack-0.4alpha/mspack/lzxd.c
rename to libclamav/libmspack-0.5alpha/mspack/lzxd.c
--- a/libclamav/libmspack-0.4alpha/mspack/lzxd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/lzxd.c
@@ -506,8 +506,7 @@ int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes) {
 	  lzx->intel_started = 1;
 
 	  /* read 1-16 (not 0-15) bits to align to bytes */
-	  ENSURE_BITS(16);
-	  if (bits_left > 16) i_ptr -= 2;
+	  if (bits_left == 0) ENSURE_BITS(16);
 	  bits_left = 0; bit_buffer = 0;
 
 	  /* read 12 bytes of stored R0 / R1 / R2 values */
@@ -811,7 +810,8 @@ int lzxd_decompress(struct lzxd_stream *lzx, off_t out_bytes) {
 
     /* check that we've used all of the previous frame first */
     if (lzx->o_ptr != lzx->o_end) {
-      D(("%ld avail bytes, new %d frame", lzx->o_end-lzx->o_ptr, frame_size))
+      D(("%ld avail bytes, new %d frame",
+          (long)(lzx->o_end - lzx->o_ptr), frame_size))
       return lzx->error = MSPACK_ERR_DECRUNCH;
     }
 
diff --git a/libclamav/libmspack-0.4alpha/mspack/mspack.h b/libclamav/libmspack-0.5alpha/mspack/mspack.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/mspack.h
rename to libclamav/libmspack-0.5alpha/mspack/mspack.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/mszip.h b/libclamav/libmspack-0.5alpha/mspack/mszip.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/mszip.h
rename to libclamav/libmspack-0.5alpha/mspack/mszip.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/mszipc.c b/libclamav/libmspack-0.5alpha/mspack/mszipc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/mszipc.c
rename to libclamav/libmspack-0.5alpha/mspack/mszipc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/mszipd.c b/libclamav/libmspack-0.5alpha/mspack/mszipd.c
similarity index 99%
rename from libclamav/libmspack-0.4alpha/mspack/mszipd.c
rename to libclamav/libmspack-0.5alpha/mspack/mszipd.c
--- a/libclamav/libmspack-0.4alpha/mspack/mszipd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/mszipd.c
@@ -264,7 +264,7 @@ static int inflate(struct mszipd_stream *zip) {
 	  length += lit_lengths[code];
 
 	  READ_HUFFSYM(DISTANCE, code);
-	  if (code > 30) return INF_ERR_DISTCODE;
+	  if (code >= 30) return INF_ERR_DISTCODE;
 	  READ_BITS_T(distance, dist_extrabits[code]);
 	  distance += dist_offsets[code];
 
diff --git a/libclamav/libmspack-0.4alpha/mspack/oab.h b/libclamav/libmspack-0.5alpha/mspack/oab.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/oab.h
rename to libclamav/libmspack-0.5alpha/mspack/oab.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/oabc.c b/libclamav/libmspack-0.5alpha/mspack/oabc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/oabc.c
rename to libclamav/libmspack-0.5alpha/mspack/oabc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/oabd.c b/libclamav/libmspack-0.5alpha/mspack/oabd.c
similarity index 97%
rename from libclamav/libmspack-0.4alpha/mspack/oabd.c
rename to libclamav/libmspack-0.5alpha/mspack/oabd.c
--- a/libclamav/libmspack-0.4alpha/mspack/oabd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/oabd.c
@@ -259,7 +259,7 @@ static int oabd_decompress_incremental(struct msoab_decompressor *_self,
   struct mspack_file *outfh = NULL;
   unsigned char *buf = NULL;
   unsigned char hdrbuf[patchhead_SIZEOF];
-  unsigned int block_max, source_size, target_size, source_crc, target_crc;
+  unsigned int block_max, target_size;
   struct lzxd_stream *lzx = NULL;
   struct mspack_system oabd_sys;
   struct oabd_file in_ofh, out_ofh;
@@ -287,10 +287,7 @@ static int oabd_decompress_incremental(struct msoab_decompressor *_self,
   }
 
   block_max = EndGetI32(&hdrbuf[patchhead_BlockMax]);
-  source_size = EndGetI32(&hdrbuf[patchhead_SourceSize]);
   target_size = EndGetI32(&hdrbuf[patchhead_TargetSize]);
-  source_crc = EndGetI32(&hdrbuf[patchhead_SourceCRC]);
-  target_crc = EndGetI32(&hdrbuf[patchhead_TargetCRC]);
 
   /* We use it for reading block headers too */
   if (block_max < patchblk_SIZEOF)
diff --git a/libclamav/libmspack-0.4alpha/mspack/qtm.h b/libclamav/libmspack-0.5alpha/mspack/qtm.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/qtm.h
rename to libclamav/libmspack-0.5alpha/mspack/qtm.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/qtmd.c b/libclamav/libmspack-0.5alpha/mspack/qtmd.c
similarity index 99%
rename from libclamav/libmspack-0.4alpha/mspack/qtmd.c
rename to libclamav/libmspack-0.5alpha/mspack/qtmd.c
--- a/libclamav/libmspack-0.4alpha/mspack/qtmd.c
+++ b/libclamav/libmspack-0.5alpha/mspack/qtmd.c
@@ -296,10 +296,9 @@ int qtmd_decompress(struct qtmd_stream *qtm, off_t out_bytes) {
 
     /* decode more, up to the number of bytes needed, the frame boundary,
      * or the window boundary, whichever comes first */
-    if (frame_todo < (out_bytes - (qtm->o_end - qtm->o_ptr))) {
+    frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr));
+    if ((window_posn + frame_todo) < frame_end) {
       frame_end = window_posn + frame_todo;
-    } else {
-      frame_end = window_posn + (out_bytes - (qtm->o_end - qtm->o_ptr));
     }
     if (frame_end > qtm->window_size) {
       frame_end = qtm->window_size;
diff --git a/libclamav/libmspack-0.4alpha/mspack/readbits.h b/libclamav/libmspack-0.5alpha/mspack/readbits.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/readbits.h
rename to libclamav/libmspack-0.5alpha/mspack/readbits.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/readhuff.h b/libclamav/libmspack-0.5alpha/mspack/readhuff.h
similarity index 96%
rename from libclamav/libmspack-0.4alpha/mspack/readhuff.h
rename to libclamav/libmspack-0.5alpha/mspack/readhuff.h
--- a/libclamav/libmspack-0.4alpha/mspack/readhuff.h
+++ b/libclamav/libmspack-0.5alpha/mspack/readhuff.h
@@ -1,5 +1,5 @@
 /* This file is part of libmspack.
- * (C) 2003-2010 Stuart Caie.
+ * (C) 2003-2014 Stuart Caie.
  *
  * libmspack is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License (LGPL) version 2.1
@@ -10,8 +10,7 @@
 #ifndef MSPACK_READHUFF_H
 #define MSPACK_READHUFF_H 1
 
-/* This implements a fast Huffman tree decoding system.
- */
+/* This implements a fast Huffman tree decoding system. */
 
 #if !(defined(BITS_ORDER_MSB) || defined(BITS_ORDER_LSB))
 # error "readhuff.h is used in conjunction with readbits.h, include that first"
@@ -140,6 +139,7 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits,
     for (bit_num = nbits+1; bit_num <= HUFF_MAXBITS; bit_num++) {
 	for (sym = 0; sym < nsyms; sym++) {
 	    if (length[sym] != bit_num) continue;
+            if (pos >= table_mask) return 1; /* table overflow */
 
 #ifdef BITS_ORDER_MSB
 	    leaf = pos >> 16;
@@ -161,8 +161,7 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits,
 		if ((pos >> (15-fill)) & 1) leaf++;
 	    }
 	    table[leaf] = sym;
-
-	    if ((pos += bit_mask) > table_mask) return 1; /* table overflow */
+	    pos += bit_mask;
 	}
 	bit_mask >>= 1;
     }
diff --git a/libclamav/libmspack-0.4alpha/mspack/sha.h b/libclamav/libmspack-0.5alpha/mspack/sha.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/sha.h
rename to libclamav/libmspack-0.5alpha/mspack/sha.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/system.c b/libclamav/libmspack-0.5alpha/mspack/system.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/system.c
rename to libclamav/libmspack-0.5alpha/mspack/system.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/system.h b/libclamav/libmspack-0.5alpha/mspack/system.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/system.h
rename to libclamav/libmspack-0.5alpha/mspack/system.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/szdd.h b/libclamav/libmspack-0.5alpha/mspack/szdd.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/szdd.h
rename to libclamav/libmspack-0.5alpha/mspack/szdd.h
diff --git a/libclamav/libmspack-0.4alpha/mspack/szddc.c b/libclamav/libmspack-0.5alpha/mspack/szddc.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/szddc.c
rename to libclamav/libmspack-0.5alpha/mspack/szddc.c
diff --git a/libclamav/libmspack-0.4alpha/mspack/szddd.c b/libclamav/libmspack-0.5alpha/mspack/szddd.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/mspack/szddd.c
rename to libclamav/libmspack-0.5alpha/mspack/szddd.c
diff --git a/libclamav/libmspack-0.4alpha/test/cabd_md5.c b/libclamav/libmspack-0.5alpha/test/cabd_md5.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/cabd_md5.c
rename to libclamav/libmspack-0.5alpha/test/cabd_md5.c
diff --git a/libclamav/libmspack-0.4alpha/test/cabd_memory.c b/libclamav/libmspack-0.5alpha/test/cabd_memory.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/cabd_memory.c
rename to libclamav/libmspack-0.5alpha/test/cabd_memory.c
diff --git a/libclamav/libmspack-0.4alpha/test/cabd_test.c b/libclamav/libmspack-0.5alpha/test/cabd_test.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/cabd_test.c
rename to libclamav/libmspack-0.5alpha/test/cabd_test.c
diff --git a/libclamav/libmspack-0.4alpha/test/cabrip.c b/libclamav/libmspack-0.5alpha/test/cabrip.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/cabrip.c
rename to libclamav/libmspack-0.5alpha/test/cabrip.c
diff --git a/libclamav/libmspack-0.4alpha/test/chmd_find.c b/libclamav/libmspack-0.5alpha/test/chmd_find.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/chmd_find.c
rename to libclamav/libmspack-0.5alpha/test/chmd_find.c
diff --git a/libclamav/libmspack-0.4alpha/test/chmd_md5.c b/libclamav/libmspack-0.5alpha/test/chmd_md5.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/chmd_md5.c
rename to libclamav/libmspack-0.5alpha/test/chmd_md5.c
diff --git a/libclamav/libmspack-0.4alpha/test/chmd_order.c b/libclamav/libmspack-0.5alpha/test/chmd_order.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/chmd_order.c
rename to libclamav/libmspack-0.5alpha/test/chmd_order.c
diff --git a/libclamav/libmspack-0.4alpha/test/chminfo.c b/libclamav/libmspack-0.5alpha/test/chminfo.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/chminfo.c
rename to libclamav/libmspack-0.5alpha/test/chminfo.c
diff --git a/libclamav/libmspack-0.4alpha/test/chmx.c b/libclamav/libmspack-0.5alpha/test/chmx.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/chmx.c
rename to libclamav/libmspack-0.5alpha/test/chmx.c
diff --git a/libclamav/libmspack-0.4alpha/test/error.h b/libclamav/libmspack-0.5alpha/test/error.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/error.h
rename to libclamav/libmspack-0.5alpha/test/error.h
diff --git a/libclamav/libmspack-0.4alpha/test/expand.c b/libclamav/libmspack-0.5alpha/test/expand.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/expand.c
rename to libclamav/libmspack-0.5alpha/test/expand.c
diff --git a/libclamav/libmspack-0.4alpha/test/md5.c b/libclamav/libmspack-0.5alpha/test/md5.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/md5.c
rename to libclamav/libmspack-0.5alpha/test/md5.c
diff --git a/libclamav/libmspack-0.4alpha/test/md5.h b/libclamav/libmspack-0.5alpha/test/md5.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/md5.h
rename to libclamav/libmspack-0.5alpha/test/md5.h
diff --git a/libclamav/libmspack-0.4alpha/test/md5_fh.h b/libclamav/libmspack-0.5alpha/test/md5_fh.h
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/md5_fh.h
rename to libclamav/libmspack-0.5alpha/test/md5_fh.h
diff --git a/libclamav/libmspack-0.4alpha/test/multifh.c b/libclamav/libmspack-0.5alpha/test/multifh.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/multifh.c
rename to libclamav/libmspack-0.5alpha/test/multifh.c
diff --git a/libclamav/libmspack-0.4alpha/test/oabx.c b/libclamav/libmspack-0.5alpha/test/oabx.c
similarity index 100%
rename from libclamav/libmspack-0.4alpha/test/oabx.c
rename to libclamav/libmspack-0.5alpha/test/oabx.c
diff --git a/libclamav/libmspack.c b/libclamav/libmspack.c
--- a/libclamav/libmspack.c
+++ b/libclamav/libmspack.c
@@ -382,14 +382,14 @@ int cli_scanmscab(cli_ctx *ctx, off_t sfx_offset)
 		ops_ex.max_size = max_size;
 		/* scan */
 		ret = cab_d->extract(cab_d, cab_f, tmp_fname);
-		if (ret) {
-			/* Failed to extract */
+		if (ret)
+			/* Failed to extract. Try to scan what is there */
 			cli_dbgmsg("%s() failed to extract %d\n", __func__, ret);
-		} else {
-			ret = cli_scanfile(tmp_fname, ctx);
-			if (ret == CL_VIRUS)
-				virus_num++;
-		}
+
+		ret = cli_scanfile(tmp_fname, ctx);
+		if (ret == CL_VIRUS)
+			virus_num++;
+
 		if (!ctx->engine->keeptmp) {
 			if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) {
 				free(tmp_fname);
@@ -490,14 +490,14 @@ int cli_scanmschm(cli_ctx *ctx)
 
 		/* scan */
 		ret = mschm_d->extract(mschm_d, mschm_f, tmp_fname);
-		if (ret) {
-			/* Failed to extract */
+		if (ret)
+			/* Failed to extract. Try to scan what is there */
 			cli_dbgmsg("%s() failed to extract %d\n", __func__, ret);
-		} else {
-			ret = cli_scanfile(tmp_fname, ctx);
-			if (ret == CL_VIRUS)
-				virus_num++;
-		}
+
+		ret = cli_scanfile(tmp_fname, ctx);
+		if (ret == CL_VIRUS)
+			virus_num++;
+
 		if (!ctx->engine->keeptmp) {
 			if (!access(tmp_fname, R_OK) && cli_unlink(tmp_fname)) {
 				free(tmp_fname);
diff --git a/libclamav/mbox.c b/libclamav/mbox.c
--- a/libclamav/mbox.c
+++ b/libclamav/mbox.c
@@ -3315,7 +3315,7 @@ getline_from_mbox(char *buffer, size_t buffer_len, fmap_t *map, size_t *at)
 	return NULL;
     }
     if((buffer_len == 0) || (buffer == NULL)) {
-	cli_errmsg("Invalid call to getline_from_mbox(). Refer to http://www.clamav.net/documentation.html\n";);
+	cli_errmsg("Invalid call to getline_from_mbox(). Refer to http://www.clamav.net/doc/install.html\n";);
 	return NULL;
     }
 
diff --git a/libclamav/mew.c b/libclamav/mew.c
--- a/libclamav/mew.c
+++ b/libclamav/mew.c
@@ -889,7 +889,7 @@ int unmew11(char *src, int off, int ssize, int dsize, uint32_t base, uint32_t va
 		section[0].raw = 0; section[0].rva = vadd;
 		section[0].rsz = section[0].vsz = dsize;
 	}
-	if (!cli_rebuildpe(src, section, i, base, entry_point - base, 0, 0, filedesc))
+	if (!cli_rebuildpe_align(src, section, i, base, entry_point - base, 0, 0, filedesc, 0x1000))
 	{
 		cli_dbgmsg("MEW: Rebuilding failed\n");
 		free(section);
diff --git a/libclamav/mpool.c b/libclamav/mpool.c
--- a/libclamav/mpool.c
+++ b/libclamav/mpool.c
@@ -623,7 +623,11 @@ void *mpool_malloc(struct MP *mp, size_t size) {
     struct FRAG *fold = f;
     mp->avail[sbits] = f->u.next.ptr;
     /* we always have enough space for this, align_increase ensured that */
+#ifdef _WIN64
+    f = (struct FRAG*)(alignto((unsigned long long)f + FRAG_OVERHEAD, align)-FRAG_OVERHEAD);
+#else
     f = (struct FRAG*)(alignto((unsigned long)f + FRAG_OVERHEAD, align)-FRAG_OVERHEAD);
+#endif
     f->u.a.sbits = sbits;
     f->u.a.padding = (char*)f - (char*)fold;
 #ifdef CL_DEBUG
diff --git a/libclamav/ole2_extract.c b/libclamav/ole2_extract.c
--- a/libclamav/ole2_extract.c
+++ b/libclamav/ole2_extract.c
@@ -358,22 +358,21 @@ print_ole2_header(ole2_header_t * hdr)
     if (!hdr || !cli_debug_flag) {
         return;
     }
-    cli_dbgmsg("\nMagic:\t\t\t0x");
-    for (i = 0; i < 8; i++) {
-        cli_dbgmsg("%x", hdr->magic[i]);
-    }
     cli_dbgmsg("\n");
+    cli_dbgmsg("Magic:\t\t\t0x%x%x%x%x%x%x%x%x\n",
+               hdr->magic[0], hdr->magic[1], hdr->magic[2], hdr->magic[3],
+               hdr->magic[4], hdr->magic[5], hdr->magic[6], hdr->magic[7]);
 
-    cli_dbgmsg("CLSID:\t\t\t{");
-    for (i = 0; i < 16; i++) {
-        cli_dbgmsg("%x ", hdr->clsid[i]);
-    }
-    cli_dbgmsg("}\n");
+    cli_dbgmsg("CLSID:\t\t\t{%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x}\n",
+               hdr->clsid[0],  hdr->clsid[1],  hdr->clsid[2],  hdr->clsid[3],
+               hdr->clsid[4],  hdr->clsid[5],  hdr->clsid[6],  hdr->clsid[7],
+               hdr->clsid[8],  hdr->clsid[9],  hdr->clsid[10], hdr->clsid[11],
+               hdr->clsid[12], hdr->clsid[13], hdr->clsid[14], hdr->clsid[15]);
 
     cli_dbgmsg("Minor version:\t\t0x%x\n", hdr->minor_version);
     cli_dbgmsg("DLL version:\t\t0x%x\n", hdr->dll_version);
     cli_dbgmsg("Byte Order:\t\t%d\n", hdr->byte_order);
-    cli_dbgmsg("Big Block Size:\t\t%i\n", hdr->log2_big_block_size);
+    cli_dbgmsg("Big Block Size:\t%i\n", hdr->log2_big_block_size);
     cli_dbgmsg("Small Block Size:\t%i\n", hdr->log2_small_block_size);
     cli_dbgmsg("BAT count:\t\t%d\n", hdr->bat_count);
     cli_dbgmsg("Prop start:\t\t%d\n", hdr->prop_start);
@@ -381,7 +380,8 @@ print_ole2_header(ole2_header_t * hdr)
     cli_dbgmsg("SBat start:\t\t%d\n", hdr->sbat_start);
     cli_dbgmsg("SBat block count:\t%d\n", hdr->sbat_block_count);
     cli_dbgmsg("XBat start:\t\t%d\n", hdr->xbat_start);
-    cli_dbgmsg("XBat block count:\t%d\n\n", hdr->xbat_count);
+    cli_dbgmsg("XBat block count:\t%d\n", hdr->xbat_count);
+    cli_dbgmsg("\n");
     return;
 }
 
diff --git a/libclamav/ooxml.c b/libclamav/ooxml.c
--- a/libclamav/ooxml.c
+++ b/libclamav/ooxml.c
@@ -78,11 +78,29 @@ static int ooxml_is_int(const char *value, size_t len, int32_t *val)
     return 1;
 }
 
+static int ooxml_add_parse_error(json_object *wrkptr, const xmlChar *errstr)
+{
+    json_object *perr;
+
+    if (!wrkptr)
+        return CL_ENULLARG;
+
+    perr = cli_jsonarray(wrkptr, "ParseErrors");
+    if (perr == NULL) {
+        return CL_EMEM;
+    }
+
+    return cli_jsonstr(perr, NULL, errstr);
+}
+
 static int ooxml_parse_value(json_object *wrkptr, const char *arrname, const xmlChar *node_value)
 {
     json_object *newobj, *arrobj;
     int val;
 
+    if (!wrkptr)
+        return CL_ENULLARG;
+
     arrobj = cli_jsonarray(wrkptr, arrname);
     if (arrobj == NULL) {
         return CL_EMEM;
@@ -247,7 +265,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
 
     if (node_type != XML_READER_TYPE_ELEMENT) {
         cli_dbgmsg("ooxml_parse_element: first node typed %d, not %d\n", node_type, XML_READER_TYPE_ELEMENT);
-        return CL_EPARSE; /* first type is not an element */
+        return CL_EFORMAT; /* first type is not an element */
     }
 
     node_name = xmlTextReaderConstLocalName(reader);
@@ -267,7 +285,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
     /* generate json object */
     thisjobj = cli_jsonobj(wrkptr, element_tag);
     if (!thisjobj) {
-        return CL_EPARSE;
+        return CL_EMEM;
     }
     cli_dbgmsg("ooxml_parse_element: generated json object [%s]\n", element_tag);
 
@@ -386,6 +404,17 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
     return CL_SUCCESS;
 }
 
+static int ooxml_updatelimits(int fd, cli_ctx *ctx)
+{
+    STATBUF sb;
+    if (FSTAT(fd, &sb) == -1) {
+        cli_errmsg("ooxml_updatelimits: Can't fstat descriptor %d\n", fd);
+        return CL_ESTAT;
+    }
+
+    return cli_updatelimits(ctx, sb.st_size);
+}
+
 static int ooxml_parse_document(int fd, cli_ctx *ctx)
 {
     int ret = CL_SUCCESS;
@@ -393,6 +422,11 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx)
 
     cli_dbgmsg("in ooxml_parse_document\n");
 
+    /* perform engine limit checks in temporary tracking session */
+    ret = ooxml_updatelimits(fd, ctx);
+    if (ret != CL_CLEAN)
+        return ret;
+
     reader = xmlReaderForFd(fd, "properties.xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
     if (reader == NULL) {
         cli_dbgmsg("ooxml_parse_document: xmlReaderForFd error\n");
@@ -406,10 +440,8 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx)
 
     ret = ooxml_parse_element(ctx, reader, ctx->wrkproperty, 0, NULL);
 
-    if (ret != CL_SUCCESS && ret != CL_ETIMEOUT && ret != CL_BREAK) {
+    if (ret != CL_SUCCESS && ret != CL_ETIMEOUT && ret != CL_BREAK)
         cli_warnmsg("ooxml_parse_document: encountered issue in parsing properties document\n");
-        cli_jsonbool(ctx->wrkproperty, "ParseError", 1);
-    }
 
     xmlTextReaderClose(reader);
     xmlFreeTextReader(reader);
@@ -418,37 +450,64 @@ static int ooxml_parse_document(int fd, cli_ctx *ctx)
 
 static int ooxml_core_cb(int fd, cli_ctx *ctx)
 {
+    int ret;
+
     cli_dbgmsg("in ooxml_core_cb\n");
-    return ooxml_parse_document(fd, ctx);
-    //return ooxml_basic_json(fd, ctx, "CoreProperties");
+    ret = ooxml_parse_document(fd, ctx);
+    if (ret == CL_EPARSE)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_CORE_XMLPARSER");
+    else if (ret == CL_EFORMAT)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_CORE_MALFORMED");
+
+    return ret;
 }
 
 static int ooxml_extn_cb(int fd, cli_ctx *ctx)
 {
+    int ret;
+
     cli_dbgmsg("in ooxml_extn_cb\n");
-    return ooxml_parse_document(fd, ctx);
-    //return ooxml_basic_json(fd, ctx, "ExtendedProperties");
+    ret = ooxml_parse_document(fd, ctx);
+    if (ret == CL_EPARSE)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_EXTN_XMLPARSER");
+    else if (ret == CL_EFORMAT)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_EXTN_MALFORMED");
+
+    return ret;
 }
 
 static int ooxml_content_cb(int fd, cli_ctx *ctx)
 {
-    int ret = CL_SUCCESS, tmp, toval = 0;
+    int ret = CL_SUCCESS, tmp, toval = 0, state;
     int core=0, extn=0, cust=0, dsig=0;
     int mcore=0, mextn=0, mcust=0;
     const xmlChar *name, *value, *CT, *PN;
     xmlTextReaderPtr reader = NULL;
     uint32_t loff;
 
+    unsigned long sav_scansize = ctx->scansize;
+    unsigned int sav_scannedfiles = ctx->scannedfiles;
+
     cli_dbgmsg("in ooxml_content_cb\n");
 
+    /* perform engine limit checks in temporary tracking session */
+    ret = ooxml_updatelimits(fd, ctx);
+    if (ret != CL_CLEAN)
+        return ret;
+
+    /* apply a reader to the document */
     reader = xmlReaderForFd(fd, "[Content_Types].xml", NULL, CLAMAV_MIN_XMLREADER_FLAGS);
     if (reader == NULL) {
         cli_dbgmsg("ooxml_content_cb: xmlReaderForFd error for ""[Content_Types].xml""\n");
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_XML_READER_FD");
+
+        ctx->scansize = sav_scansize;
+        ctx->scannedfiles = sav_scannedfiles;
         return CL_SUCCESS; // libxml2 failed!
     }
 
-    /* locate core-properties, extended-properties, and custom-properties (optional)  */
-    while (xmlTextReaderRead(reader) == 1) {
+    /* locate core-properties, extended-properties, and custom-properties (optional) */
+    while ((state = xmlTextReaderRead(reader)) == 1) {
         if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {
             ret = CL_ETIMEOUT;
             goto ooxml_content_exit;
@@ -480,93 +539,116 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
         if (!CT && !PN) continue;
 
         if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.core-properties+xml")) {
-            if (!core) {
-                /* default: /docProps/core.xml*/
-                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
-                if (tmp == CL_ETIMEOUT) {
-                    ret = tmp;
-                }
-                else if (tmp != CL_VIRUS) {
-                    cli_dbgmsg("cli_process_ooxml: failed to find core properties file \"%s\"!\n", PN);
-                    mcore++;
-                }
-                else {
-                    cli_dbgmsg("ooxml_content_cb: found core properties file \"%s\" @ %x\n", PN, loff);
-                    ret = unzip_single_internal(ctx, loff, ooxml_core_cb);
-                    core++;
+            /* default: /docProps/core.xml*/
+            tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
+            if (tmp == CL_ETIMEOUT) {
+                ret = tmp;
+            }
+            else if (tmp != CL_VIRUS) {
+                cli_dbgmsg("cli_process_ooxml: failed to find core properties file \"%s\"!\n", PN);
+                mcore++;
+            }
+            else {
+                cli_dbgmsg("ooxml_content_cb: found core properties file \"%s\" @ %x\n", PN, loff);
+                if (!core) {
+                    tmp = unzip_single_internal(ctx, loff, ooxml_core_cb);
+                    if (tmp == CL_ETIMEOUT || tmp == CL_EMEM) {
+                        ret = tmp;
+                    }
                 }
+                core++;
             }
         }
         else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.extended-properties+xml")) {
-            if (!extn) {
-                /* default: /docProps/app.xml */
-                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
-                if (tmp == CL_ETIMEOUT) {
-                    ret = tmp;
-                }
-                else if (tmp != CL_VIRUS) {
-                    cli_dbgmsg("cli_process_ooxml: failed to find extended properties file \"%s\"!\n", PN);
-                    mextn++;
-                }
-                else {
-                    cli_dbgmsg("ooxml_content_cb: found extended properties file \"%s\" @ %x\n", PN, loff);
-                    ret = unzip_single_internal(ctx, loff, ooxml_extn_cb);
-                    extn++;
+            /* default: /docProps/app.xml */
+            tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
+            if (tmp == CL_ETIMEOUT) {
+                ret = tmp;
+            }
+            else if (tmp != CL_VIRUS) {
+                cli_dbgmsg("cli_process_ooxml: failed to find extended properties file \"%s\"!\n", PN);
+                mextn++;
+            }
+            else {
+                cli_dbgmsg("ooxml_content_cb: found extended properties file \"%s\" @ %x\n", PN, loff);
+                if (!extn) {
+                    tmp = unzip_single_internal(ctx, loff, ooxml_extn_cb);
+                    if (tmp == CL_ETIMEOUT || tmp == CL_EMEM) {
+                        ret = tmp;
+                    }
                 }
+                extn++;
             }
         }
         else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.custom-properties+xml")) {
-            if (!cust) {
-                /* default: /docProps/custom.xml */
-                tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
-                if (tmp == CL_ETIMEOUT) {
-                    ret = tmp;
-                }
-                else if (tmp != CL_VIRUS) {
-                    cli_dbgmsg("cli_process_ooxml: failed to find custom properties file \"%s\"!\n", PN);
-                    mcust++;
-                }
-                else {
-                    cli_dbgmsg("ooxml_content_cb: found custom properties file \"%s\" @ %x\n", PN, loff);
-                    cust++;
-                    //ret = unzip_single_internal(ctx, loff, ooxml_cust_cb);
-                }
+            /* default: /docProps/custom.xml */
+            tmp = unzip_search_single(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
+            if (tmp == CL_ETIMEOUT) {
+                ret = tmp;
+            }
+            else if (tmp != CL_VIRUS) {
+                cli_dbgmsg("cli_process_ooxml: failed to find custom properties file \"%s\"!\n", PN);
+                mcust++;
+            }
+            else {
+                cli_dbgmsg("ooxml_content_cb: found custom properties file \"%s\" @ %x\n", PN, loff);
+                /* custom properties are not parsed */
+                cust++;
             }
         }
         else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")) {
             dsig++;
         }
 
-        if (ret != CL_BREAK && ret != CL_SUCCESS)
+        if (ret != CL_SUCCESS)
             goto ooxml_content_exit;
     }
 
  ooxml_content_exit:
-    if (core)
+    if (core) {
         cli_jsonint(ctx->wrkproperty, "CorePropertiesFileCount", core);
+        if (core > 1)
+            ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MULTIPLE_CORE_PROPFILES");
+    }
     else if (!mcore)
         cli_dbgmsg("cli_process_ooxml: file does not contain core properties file\n");
-    if (mcore)
-        cli_jsonint(ctx->wrkproperty, "CorePropertiesMissingFileCount", core);
+    if (mcore) {
+        cli_jsonint(ctx->wrkproperty, "CorePropertiesMissingFileCount", mcore);
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MISSING_CORE_PROPFILES");
+    }
 
-    if (extn)
+    if (extn) {
         cli_jsonint(ctx->wrkproperty, "ExtendedPropertiesFileCount", extn);
+        if (extn > 1)
+            ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MULTIPLE_EXTN_PROPFILES");
+    }
     else if (!mextn)
         cli_dbgmsg("cli_process_ooxml: file does not contain extended properties file\n");
-    if (mextn)
-        cli_jsonint(ctx->wrkproperty, "ExtendedPropertiesMissingFileCount", extn);
+    if (mextn) {
+        cli_jsonint(ctx->wrkproperty, "ExtendedPropertiesMissingFileCount", mextn);
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MISSING_EXTN_PROPFILES");
+    }
 
-    if (cust)
+    if (cust) {
         cli_jsonint(ctx->wrkproperty, "CustomPropertiesFileCount", cust);
+        if (cust > 1)
+            ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MULTIPLE_CUSTOM_PROPFILES");
+    }
     else if (!mcust)
         cli_dbgmsg("cli_process_ooxml: file does not contain custom properties file\n");
-    if (mcust)
-        cli_jsonint(ctx->wrkproperty, "CustomPropertiesMissingFileCount", cust);
+    if (mcust) {
+        cli_jsonint(ctx->wrkproperty, "CustomPropertiesMissingFileCount", mcust);
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_MISSING_CUST_PROPFILES");
+    }
 
     if (dsig) {
         cli_jsonint(ctx->wrkproperty, "DigitalSignaturesCount", dsig);
     }
 
+    /* restore the engine tracking limits; resets session limit tracking */
+    ctx->scansize = sav_scansize;
+    ctx->scannedfiles = sav_scannedfiles;
+
     xmlTextReaderClose(reader);
     xmlFreeTextReader(reader);
     return ret;
@@ -620,15 +702,27 @@ int cli_process_ooxml(cli_ctx *ctx)
     /* find "[Content Types].xml" */
     tmp = unzip_search_single(ctx, "[Content_Types].xml", 18, &loff);
     if (tmp == CL_ETIMEOUT) {
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_TIMEOUT");
         return CL_ETIMEOUT;
     }
     else if (tmp != CL_VIRUS) {
         cli_dbgmsg("cli_process_ooxml: failed to find ""[Content_Types].xml""!\n");
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_NO_CONTENT_TYPES");
         return CL_EFORMAT;
     }
     cli_dbgmsg("cli_process_ooxml: found ""[Content_Types].xml"" @ %x\n", loff);
 
-    return unzip_single_internal(ctx, loff, ooxml_content_cb);
+    tmp = unzip_single_internal(ctx, loff, ooxml_content_cb);
+    if (tmp == CL_ETIMEOUT)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_TIMEOUT");
+    else if (tmp == CL_EMEM)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_OUTOFMEM");
+    else if (tmp == CL_EMAXSIZE)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_EMAXSIZE");
+    else if (tmp == CL_EMAXFILES)
+        ooxml_add_parse_error(ctx->wrkproperty, "OOXML_ERROR_EMAXFILES");
+
+    return tmp;
 #else
     UNUSEDPARAM(ctx);
     cli_dbgmsg("in cli_processooxml\n");
diff --git a/libclamav/pe.c b/libclamav/pe.c
--- a/libclamav/pe.c
+++ b/libclamav/pe.c
@@ -2570,9 +2570,26 @@ int cli_scanpe(cli_ctx *ctx)
             cli_jsonstr(pe_json, "Packer", "yC");
 #endif
 
-            cli_dbgmsg("%d,%d,%d,%d\n", nsections-1, e_lfanew, ecx, offset);
-            CLI_UNPTEMP("yC",(spinned,exe_sections,0));
-            CLI_UNPRESULTS("yC",(yc_decrypt(spinned, fsize, exe_sections, nsections-1, e_lfanew, ndesc, ecx, offset)),0,(spinned,0));
+            do {
+                unsigned int yc_unp_num_viruses = ctx->num_viruses;
+                const char *yc_unp_virname = NULL;
+
+                if (ctx->virname)
+                    yc_unp_virname = ctx->virname[0];
+
+                cli_dbgmsg("%d,%d,%d,%d\n", nsections-1, e_lfanew, ecx, offset);
+                CLI_UNPTEMP("yC",(spinned,exe_sections,0));
+                CLI_UNPRESULTS("yC",(yc_decrypt(ctx, spinned, fsize, exe_sections, nsections-1, e_lfanew, ndesc, ecx, offset)),0,(spinned,0));
+
+                if (SCAN_ALL && yc_unp_num_viruses != ctx->num_viruses) {
+                    free(exe_sections);
+                    return CL_VIRUS;
+                }
+                else if (ctx->virname && yc_unp_virname != ctx->virname[0]) {
+                    free(exe_sections);
+                    return CL_VIRUS;
+                }
+            } while(0);
         }
     }
 
diff --git a/libclamav/petite.c b/libclamav/petite.c
--- a/libclamav/petite.c
+++ b/libclamav/petite.c
@@ -108,7 +108,8 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, uint32_t bufsz, struct cli
   while (1) {
     char *ssrc, *ddst;
     uint32_t size, srva;
-    int backbytes, oldback, backsize, addsize;
+    int backbytes, oldback, addsize;
+    unsigned int backsize;
     
     if ( ! CLI_ISCONTAINED(buf, bufsz, packed, 4)) {
       if (usects)
diff --git a/libclamav/rebuildpe.c b/libclamav/rebuildpe.c
--- a/libclamav/rebuildpe.c
+++ b/libclamav/rebuildpe.c
@@ -121,6 +121,11 @@ struct IMAGE_PE_HEADER {
 
 int cli_rebuildpe(char *buffer, struct cli_exe_section *sections, int sects, uint32_t base, uint32_t ep, uint32_t ResRva, uint32_t ResSize, int file)
 {
+  return cli_rebuildpe_align(buffer, sections, sects, base, ep, ResRva, ResSize, file, 0);
+}
+
+int cli_rebuildpe_align(char *buffer, struct cli_exe_section *sections, int sects, uint32_t base, uint32_t ep, uint32_t ResRva, uint32_t ResSize, int file, uint32_t align)
+{
   uint32_t datasize=0, rawbase=PESALIGN(0x148+0x80+0x28*sects, 0x200);
   char *pefile=NULL, *curpe;
   struct IMAGE_PE_HEADER *fakepe;
@@ -131,8 +136,12 @@ int cli_rebuildpe(char *buffer, struct cli_exe_section *sections, int sects, uin
   if(sects+gotghost > 96)
     return 0;
 
-  for (i=0; i < sects; i++)
-    datasize+=PESALIGN(sections[i].rsz, 0x200);
+  if (!align)
+    for (i=0; i < sects; i++)
+      datasize+=PESALIGN(sections[i].rsz, 0x200);
+  else
+    for (i=0; i < sects; i++)
+      datasize+=PESALIGN(PESALIGN(sections[i].rsz, align), 0x200);
 
   if(datasize > CLI_MAX_ALLOCATION)
     return 0;
@@ -163,10 +172,17 @@ int cli_rebuildpe(char *buffer, struct cli_exe_section *sections, int sects, uin
 
     for (i=0; i < sects; i++) {
       snprintf(curpe, 8, ".clam%.2d", i+1);
-      cli_writeint32(curpe+8, sections[i].vsz);
-      cli_writeint32(curpe+12, sections[i].rva);
-      cli_writeint32(curpe+16, sections[i].rsz);
-      cli_writeint32(curpe+20, rawbase);
+      if (!align) {
+        cli_writeint32(curpe+8, sections[i].vsz);
+        cli_writeint32(curpe+12, sections[i].rva);
+        cli_writeint32(curpe+16, sections[i].rsz);
+        cli_writeint32(curpe+20, rawbase);
+      } else {
+        cli_writeint32(curpe+8, PESALIGN(sections[i].vsz, align));
+        cli_writeint32(curpe+12, PESALIGN(sections[i].rva, align));
+        cli_writeint32(curpe+16, PESALIGN(sections[i].rsz, align));
+        cli_writeint32(curpe+20, rawbase);
+      }
       /* already zeroed
       cli_writeint32(curpe+24, 0);
       cli_writeint32(curpe+28, 0);
@@ -174,9 +190,14 @@ int cli_rebuildpe(char *buffer, struct cli_exe_section *sections, int sects, uin
       */
       cli_writeint32(curpe+0x24, 0xffffffff);
       memcpy(pefile+rawbase, buffer+sections[i].raw, sections[i].rsz);
-      rawbase+=PESALIGN(sections[i].rsz, 0x200);
       curpe+=40;
-      datasize+=PESALIGN(sections[i].vsz, 0x1000);
+      if (!align) {
+        rawbase+=PESALIGN(sections[i].rsz, 0x200);
+        datasize+=PESALIGN(sections[i].vsz, 0x1000);
+      } else {
+        rawbase+=PESALIGN(PESALIGN(sections[i].rsz, align), 0x200);
+        datasize+=PESALIGN(PESALIGN(sections[i].vsz, align), 0x1000);
+      }
     }
     fakepe->SizeOfImage = EC32(datasize);
   } else {
diff --git a/libclamav/rebuildpe.h b/libclamav/rebuildpe.h
--- a/libclamav/rebuildpe.h
+++ b/libclamav/rebuildpe.h
@@ -25,5 +25,6 @@
 #include "execs.h"
 
 int cli_rebuildpe(char *, struct cli_exe_section *, int, uint32_t, uint32_t, uint32_t, uint32_t, int);
+int cli_rebuildpe_align(char *, struct cli_exe_section *, int, uint32_t, uint32_t, uint32_t, uint32_t, int, uint32_t);
 
 #endif
diff --git a/libclamav/scanners.c b/libclamav/scanners.c
--- a/libclamav/scanners.c
+++ b/libclamav/scanners.c
@@ -2371,7 +2371,9 @@ static int dispatch_prescan(clcb_pre_scan cb, cli_ctx *ctx, const char *filetype
             cli_dbgmsg("cli_magic_scandesc: file whitelisted by callback\n");
             perf_stop(ctx, PERFT_PRECB);
             ctx->hook_lsig_matches = old_hook_lsig_matches;
+            /* returns CL_CLEAN */
             *run_cleanup = 1;
+            break;
         case CL_VIRUS:
             cli_dbgmsg("cli_magic_scandesc: file blacklisted by callback\n");
             cli_append_virus(ctx, "Detected.By.Callback");
@@ -2379,6 +2381,7 @@ static int dispatch_prescan(clcb_pre_scan cb, cli_ctx *ctx, const char *filetype
             ctx->hook_lsig_matches = old_hook_lsig_matches;
             *run_cleanup = 1;
             res = CL_VIRUS;
+            break;
         case CL_CLEAN:
             break;
         default:
@@ -2636,11 +2639,13 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
 #if HAVE_JSON
             if ((ctx->options & CL_SCAN_FILE_PROPERTIES) && (ctx->wrkproperty != NULL)) {
                 ret = cli_process_ooxml(ctx);
-                if (ret == CL_ETIMEOUT) {
-                    return magic_scandesc_cleanup(ctx, type, hash, hashed_size, cache_clean, ret, parent_property);
+                if (ret == CL_EMEM || ret == CL_ENULLARG) {
+                    /* critical error */
+                    break;
                 }
                 else if (ret != CL_SUCCESS) {
-                    /* JSONOOXML - what to do if something else fails? placeholder */
+                    /* allow for the CL_TYPE_ZIP scan to occur; cli_process_ooxml other possible returns: */
+                    /* CL_ETIMEOUT, CL_EMAXSIZE, CL_EMAXFILES, CL_EPARSE, CL_EFORMAT, CL_BREAK, CL_ESTAT  */
                     ret = CL_SUCCESS;
                 }
             }
diff --git a/libclamav/tnef.c b/libclamav/tnef.c
--- a/libclamav/tnef.c
+++ b/libclamav/tnef.c
@@ -166,7 +166,7 @@ cli_tnef(const char *dir, cli_ctx *ctx)
 					if(fout >= 0) {
 						int count;
 
-						cli_warnmsg("Saving dump to %s:  refer to http://www.clamav.net/documentation.html\n";, filename);
+						cli_warnmsg("Saving dump to %s:  refer to http://www.clamav.net/doc/install.html\n";, filename);
 
 						pos = 0;
 						while ((count = fmap_readn(*ctx->fmap, buffer, pos, sizeof(buffer))) > 0) {
diff --git a/libclamav/unzip.c b/libclamav/unzip.c
--- a/libclamav/unzip.c
+++ b/libclamav/unzip.c
@@ -541,7 +541,7 @@ int cli_unzip(cli_ctx *ctx) {
 	  }
 #if HAVE_JSON
           if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {
-              return CL_ETIMEOUT;
+              ret=CL_ETIMEOUT;
           }
 #endif
 
@@ -562,7 +562,7 @@ int cli_unzip(cli_ctx *ctx) {
       }
 #if HAVE_JSON
       if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {
-          return CL_ETIMEOUT;
+          ret=CL_ETIMEOUT;
       }
 #endif
 
@@ -668,7 +668,7 @@ int unzip_search(cli_ctx *ctx, fmap_t *map, struct zip_requests *requests)
         cli_dbgmsg("unzip_search: central @%x\n", coff);
         while(ret==CL_CLEAN && (coff=chdr(zmap, coff, fsize, NULL, fc+1, &ret, ctx, NULL, requests))) {
             if (requests->match) {
-                return CL_VIRUS;
+                ret=CL_VIRUS;
             }
 
             fc++;
@@ -678,7 +678,7 @@ int unzip_search(cli_ctx *ctx, fmap_t *map, struct zip_requests *requests)
             }
 #if HAVE_JSON
             if (ctx && cli_json_timeout_cycle_check(ctx, (int *)(&toval)) != CL_SUCCESS) {
-                return CL_ETIMEOUT;
+                ret=CL_ETIMEOUT;
             }
 #endif
         }
diff --git a/libclamav/upack.c b/libclamav/upack.c
--- a/libclamav/upack.c
+++ b/libclamav/upack.c
@@ -213,12 +213,17 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin
 			loc_edi = dest+vma-base; /* XXX not enough samples provided to be sure of it! */
 
 		pushed_esi = loc_edi;
-		end_edi = dest + cli_readint32(loc_esi + 0x34) - vma;
 		if (upack_version == UPACK_0297729)
 		{
 			end_edi = dest + cli_readint32(loc_esi + 0x64) - vma;
 			save3 = cli_readint32(loc_esi + 0x40);
-		}
+		} else {
+                        end_edi = dest + cli_readint32(loc_esi + 0x34) - vma;
+                }
+                if (loc_edi > end_edi) {
+                        cli_dbgmsg("Upack: loc_edi > end_edi breaks cli_rebuildpe() bb#11216\n");
+                        return -1;
+                }
 		/* begin end */
 		cli_dbgmsg("Upack: data initialized, before upack lzma call!\n");
 		if ((ret = (uint32_t)unupack399(dest, dsize, 0, loc_ebx, 0, loc_edi, end_edi, shlsize, paddr)) == 0xffffffff)
@@ -376,6 +381,10 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin
 			end_edi = dest + cli_readint32(loc_esi-0x28) - base; /* read checked above */
 			loc_esi = save_edi;
 		}
+                if (loc_edi > end_edi) {
+                        cli_dbgmsg("Upack(alt begin): loc_edi > end_edi breaks cli_rebuildpe() bb#11216\n");
+                        return -1;
+                }
 		cli_dbgmsg("Upack: data initialized, before upack lzma call!\n");
 		if ((ret = (uint32_t)unupack399(dest, dsize, loc_ecx, loc_ebx, loc_ecx, loc_edi, end_edi, shlsize, paddr)) == 0xffffffff)
 			return -1;
diff --git a/libclamav/upx.c b/libclamav/upx.c
--- a/libclamav/upx.c
+++ b/libclamav/upx.c
@@ -222,6 +222,10 @@ static int pefromupx (const char *src, uint32_t ssize, char *dst, uint32_t *dsiz
     cli_writeint32(sections+12, urva);
     cli_writeint32(sections+16, vsize);
     cli_writeint32(sections+20, foffset);
+    if (foffset + vsize < foffset) {
+        /* Integer overflow */
+        return 0;
+    }
     foffset+=vsize;
     
     sections+=0x28;
@@ -239,7 +243,20 @@ static int pefromupx (const char *src, uint32_t ssize, char *dst, uint32_t *dsiz
   memcpy(newbuf+0xd0, pehdr,0xf8+0x28*sectcnt);
   sections = pehdr+0xf8;
   for (upd = 0; upd <sectcnt ; upd++) {
-    memcpy(newbuf+cli_readint32(sections+20), dst+cli_readint32(sections+12)-upx0, cli_readint32(sections+16));
+      uint32_t offset1, offset2, offset3;
+      offset1 = (uint32_t)cli_readint32(sections+20);
+      offset2 = (uint32_t)cli_readint32(sections+16);
+      if (offset1 > foffset || offset2 > foffset || offset1 + offset2 > foffset) {
+          free(newbuf);
+          return 1;
+      }
+
+      offset3 = (uint32_t)cli_readint32(sections+12);
+      if (offset3-upx0 > *dsize) {
+          free(newbuf);
+          return 1;
+      }
+    memcpy(newbuf+offset1, dst+offset3-upx0, offset2);
     sections+=0x28;
   }
 
diff --git a/libclamav/version.h b/libclamav/version.h
--- a/libclamav/version.h
+++ b/libclamav/version.h
@@ -1 +1 @@
-#define REPO_VERSION "devel-clamav-0.98.5"
+#define REPO_VERSION "devel-clamav-0.98.6"
diff --git a/libclamav/yc.c b/libclamav/yc.c
--- a/libclamav/yc.c
+++ b/libclamav/yc.c
@@ -39,10 +39,26 @@
 
 #define EC16(x) le16_to_host(x) /* Convert little endian to host */
 
+#define DO_HEURISTIC 1
+
+static int yc_bounds_check(cli_ctx *ctx, char *base, unsigned int filesize, char *offset, unsigned int bound)
+{
+      if ((unsigned int)((offset+bound)-base) > filesize) {
+          cli_dbgmsg("yC: Bounds check assertion.\n");
+#if DO_HEURISTIC
+          cli_append_virus(ctx, "Heuristics.BoundsCheck");
+#endif
+          return 1;
+      }
+
+      return 0;
+}
+
+
 /* ========================================================================== */
 /* "Emulates" the poly decryptors */
 
-static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx, uint32_t max_emu)
+static int yc_poly_emulator(cli_ctx *ctx, char *base, unsigned int filesize, char* decryptor_offset, char* code, unsigned int ecx, uint32_t max_emu)
 {
 
   /* 
@@ -68,15 +84,25 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
 
   for(i=0;i<ecx&&i<max_emu;i++) /* Byte looper - Decrypts every byte and write it back */
     {
+        if (yc_bounds_check(ctx, base, filesize, code, i)) {
+            return 2;
+        }
       al = code[i];
 
       for(j=0;j<0x30;j++)   /* Poly Decryptor "Emulator" */
 	{
+        if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+            return 2;
+        }
+
 	  switch(decryptor_offset[j])
 	    {
 
 	    case '\xEB':	/* JMP short */
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      j = j + decryptor_offset[j];
 	      break;
 
@@ -102,36 +128,57 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
 	      ;
 	    case '\x04':	/* ADD AL,num */
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      al = al + decryptor_offset[j];
 	      break;
 	      ;
 	    case '\x34':	/* XOR AL,num */
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      al = al ^ decryptor_offset[j];
 	      break;
 
 	    case '\x2C':	/* SUB AL,num */
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      al = al - decryptor_offset[j];
 	      break;
 
 			
 	    case '\xC0':
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      if(decryptor_offset[j]=='\xC0') /* ROL AL,num */
 		{
 		  j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 		  CLI_ROL(al,decryptor_offset[j]);
 		}
 	      else			/* ROR AL,num */
 		{
 		  j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 		  CLI_ROR(al,decryptor_offset[j]);
 		}
 	      break;
 
 	    case '\xD2':
 	      j++;
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      if(decryptor_offset[j]=='\xC8') /* ROR AL,CL */
 		{
 		  j++;
@@ -150,11 +197,16 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
 	      break;
 
 	    default:
+            if (yc_bounds_check(ctx, base, filesize, decryptor_offset, j)) {
+                return 2;
+            }
 	      cli_dbgmsg("yC: Unhandled opcode %x\n", (unsigned char)decryptor_offset[j]);
 	      return 1;
 	    }
 	}
       cl--;
+            if (yc_bounds_check(ctx, base, filesize, code, i))
+                return 2;
       code[i] = al;
     }
   return 0;
@@ -165,12 +217,13 @@ static int yc_poly_emulator(char* decryptor_offset, char* code, unsigned int ecx
 /* ========================================================================== */
 /* Main routine which calls all others */
 
-int yc_decrypt(char *fbuf, unsigned int filesize, struct cli_exe_section *sections, unsigned int sectcount, uint32_t peoffset, int desc, uint32_t ecx,int16_t offset) {
+int yc_decrypt(cli_ctx *ctx, char *fbuf, unsigned int filesize, struct cli_exe_section *sections, unsigned int sectcount, uint32_t peoffset, int desc, uint32_t ecx,int16_t offset) {
   uint32_t ycsect = sections[sectcount].raw+offset;
   unsigned int i;
   struct pe_image_file_hdr *pe = (struct pe_image_file_hdr*) (fbuf + peoffset);
   char *sname = (char *)pe + EC16(pe->SizeOfOptionalHeader) + 0x18;
   uint32_t max_emu;
+  unsigned int ofilesize = filesize;
   /* 
 
   First layer (decryptor of the section decryptor) in last section 
@@ -182,8 +235,12 @@ int yc_decrypt(char *fbuf, unsigned int filesize, struct cli_exe_section *sectio
   */
   cli_dbgmsg("yC: offset: %x, length: %x\n", offset, ecx);
   cli_dbgmsg("yC: decrypting decryptor on sect %d\n", sectcount);
-  if (yc_poly_emulator(fbuf + ycsect + 0x93, fbuf + ycsect + 0xc6, ecx, ecx))
-    return 1;
+  switch (yc_poly_emulator(ctx, fbuf, filesize, fbuf + ycsect + 0x93, fbuf + ycsect + 0xc6, ecx, ecx)) {
+  case 2:
+      return CL_VIRUS;
+  case 1:
+      return CL_EUNPACK;
+  }
   filesize-=sections[sectcount].ursz;
 
   /* 
@@ -218,11 +275,15 @@ int yc_decrypt(char *fbuf, unsigned int filesize, struct cli_exe_section *sectio
       cli_dbgmsg("yC: bad emulation length limit %u\n", max_emu);
       return 1;
     }
-    if (yc_poly_emulator(fbuf + ycsect + (offset == -0x18 ? 0x3ea : 0x457), 
+    switch (yc_poly_emulator(ctx, fbuf, ofilesize, fbuf + ycsect + (offset == -0x18 ? 0x3ea : 0x457), 
 			 fbuf + sections[i].raw, 
 			 sections[i].ursz, 
-			 max_emu))
-      return 1;
+			 max_emu)) {
+    case 2:
+        return CL_VIRUS;
+    case 1:
+        return CL_EUNPACK;
+    }
   }
 
   /* Remove yC section */
@@ -240,7 +301,7 @@ int yc_decrypt(char *fbuf, unsigned int filesize, struct cli_exe_section *sectio
 
   if (cli_writen(desc, fbuf, filesize)==-1) {
     cli_dbgmsg("yC: Cannot write unpacked file\n");
-    return 1;
+    return CL_EUNPACK;
   }
-  return 0;
+  return CL_SUCCESS;
 }
diff --git a/libclamav/yc.h b/libclamav/yc.h
--- a/libclamav/yc.h
+++ b/libclamav/yc.h
@@ -25,6 +25,6 @@
 #include "execs.h"
 #include "cltypes.h"
 
-int yc_decrypt(char *, unsigned int, struct cli_exe_section *, unsigned int, uint32_t, int,uint32_t,int16_t);
+int yc_decrypt(cli_ctx *, char *, unsigned int, struct cli_exe_section *, unsigned int, uint32_t, int,uint32_t,int16_t);
 
 #endif
diff --git a/m4/reorganization/version.m4 b/m4/reorganization/version.m4
--- a/m4/reorganization/version.m4
+++ b/m4/reorganization/version.m4
@@ -1,9 +1,9 @@
 dnl change this on a release
 dnl VERSION="devel-`date +%Y%m%d`"
-VERSION="0.98.5"
+VERSION="0.98.6"
 
 LC_CURRENT=7
-LC_REVISION=24
+LC_REVISION=25
 LC_AGE=1
 LIBCLAMAV_VERSION="$LC_CURRENT":"$LC_REVISION":"$LC_AGE"
 AC_SUBST([LIBCLAMAV_VERSION])
diff --git a/shared/optparser.c b/shared/optparser.c
--- a/shared/optparser.c
+++ b/shared/optparser.c
@@ -295,13 +295,13 @@ const struct clam_option __clam_options[] = {
 	"Allow loading bytecode from outside digitally signed .c[lv]d files.","no"},
 
     { "BytecodeMode", "bytecode-mode", 0, CLOPT_TYPE_STRING, "^(Auto|ForceJIT|ForceInterpreter|Test)$", -1, "Auto", FLAG_REQUIRED, OPT_CLAMD | OPT_CLAMSCAN,
-	"Set bytecode execution mode.\nPossible values:\n\tAuto - automatically choose JIT if possible, fallback to interpreter\nForceJIT - always choose JIT, fail if not possible\nForceIntepreter - always choose interpreter\nTest - run with both JIT and interpreter and compare results. Make all failures fatal.","Auto"},
+	"Set bytecode execution mode.\nPossible values:\n\tAuto - automatically choose JIT if possible, fallback to interpreter\nForceJIT - always choose JIT, fail if not possible\nForceInterpreter - always choose interpreter\nTest - run with both JIT and interpreter and compare results. Make all failures fatal.","Auto"},
 
     { "BytecodeStatistics", "bytecode-statistics", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMSCAN | OPT_CLAMBC, "Collect and print bytecode execution statistics.", "no" },
 
    { "DetectPUA", "detect-pua", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Detect Potentially Unwanted Applications.", "yes" },
 
-    { "ExcludePUA", "exclude-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/documentation.html#pua for the complete list of PUA\ncategories.", "NetTool\nPWTool" },
+    { "ExcludePUA", "exclude-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/doc/pua.html for the complete list of PUA\ncategories.", "NetTool\nPWTool" },
 
     { "IncludePUA", "include-pua", 0, CLOPT_TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Only include a specific PUA category. This directive can be used multiple\ntimes.", "Spy\nScanner\nRAT" },
 
@@ -458,9 +458,9 @@ const struct clam_option __clam_options[] = {
 
     { "DetectionStatsCountry", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "Country of origin of malware/detection statistics (for statistical\npurposes only). The statistics collector at ClamAV.net will look up\nyour IP address to determine the geographical origin of the malware\nreported by your installation. If this installation is mainly used to\nscan data which comes from a different location, please enable this\noption and enter a two-letter code (see http://www.iana.org/domains/root/db/)\nof the country of origin.", "country-code" },
 
-    { "DetectionStatsHostID", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "This option enables support for our \"Personal Statistics\" service.\nWhen this option is enabled, the information on malware detected by\nyour clamd installation is made available to you through our website.\nTo get your HostID, log on http://www.stats.clamav.net and add a new\nhost to your host list. Once you have the HostID, uncomment this option\nand paste the HostID here. As soon as your freshclam starts submitting\ninformation to our stats collecting service, you will be able to view\nthe statistics of this clamd installation by logging into\nhttp://www.stats.clamav.net with the same credentials you used to\ngenerate the HostID. For more information refer to:\nhttp://www.clamav.net/documentation.html#cctts\nThis feature requires SubmitDetectionStats to be enabled.", "unique-id" },
+    { "DetectionStatsHostID", NULL, 0, CLOPT_TYPE_STRING, NULL, -1, NULL, 0, OPT_FRESHCLAM, "This option enables support for our \"Personal Statistics\" service.\nWhen this option is enabled, the information on malware detected by\nyour clamd installation is made available to you through our website.\nTo get your HostID, log on http://www.stats.clamav.net and add a new\nhost to your host list. Once you have the HostID, uncomment this option\nand paste the HostID here. As soon as your freshclam starts submitting\ninformation to our stats collecting service, you will be able to view\nthe statistics of this clamd installation by logging into\nhttp://www.stats.clamav.net with the same credentials you used to\ngenerate the HostID. For more information refer to:\nhttp://www.clamav.net/doc/cctts.html\nThis feature requires SubmitDetectionStats to be enabled.", "unique-id" },
 
-    { "SafeBrowsing", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "This option enables support for Google Safe Browsing. When activated for\nthe first time, freshclam will download a new database file (safebrowsing.cvd)\nwhich will be automatically loaded by clamd and clamscan during the next\nreload, provided that the heuristic phishing detection is turned on. This\ndatabase includes information about websites that may be phishing sites or\npossible sources of malware. When using this option, it's mandatory to run\nfreshclam at least every 30 minutes.\nFreshclam uses the ClamAV's mirror infrastructure to distribute the\ndatabase and its updates but all the contents are provided under Google's\nterms of use. See http://www.google.com/transparencyreport/safebrowsing\nand http://www.clamav.net/documentation.html for more information.", "yes" },
+    { "SafeBrowsing", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_FRESHCLAM, "This option enables support for Google Safe Browsing. When activated for\nthe first time, freshclam will download a new database file (safebrowsing.cvd)\nwhich will be automatically loaded by clamd and clamscan during the next\nreload, provided that the heuristic phishing detection is turned on. This\ndatabase includes information about websites that may be phishing sites or\npossible sources of malware. When using this option, it's mandatory to run\nfreshclam at least every 30 minutes.\nFreshclam uses the ClamAV's mirror infrastructure to distribute the\ndatabase and its updates but all the contents are provided under Google's\nterms of use. See http://www.google.com/transparencyreport/safebrowsing\nand http://www.clamav.net/doc/safebrowsing.html for more information.", "yes" },
 
     { "Bytecode", NULL, 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_FRESHCLAM, "This option enables downloading of bytecode.cvd, which includes additional\ndetection mechanisms and improvements to the ClamAV engine.", "yes" },
 
diff --git a/sigtool/Makefile.am b/sigtool/Makefile.am
--- a/sigtool/Makefile.am
+++ b/sigtool/Makefile.am
@@ -37,6 +37,6 @@ sigtool_SOURCES = \
 
 AM_CFLAGS=@WERR_CFLAGS@
 DEFS = @DEFS@ -DCL_NOTHREADS
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SIGTOOL_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @SIGTOOL_CPPFLAGS@
 LIBS = @SSL_LDFLAGS@ @SSL_LIBS@ $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @THREAD_LIBS@
 CLEANFILES=*.gcda *.gcno
diff --git a/sigtool/Makefile.in b/sigtool/Makefile.in
--- a/sigtool/Makefile.in
+++ b/sigtool/Makefile.in
@@ -456,7 +456,7 @@ sigtool_SOURCES = \
     sigtool.c
 
 AM_CFLAGS = @WERR_CFLAGS@
-AM_CPPFLAGS = @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SIGTOOL_CPPFLAGS@
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav @SSL_CPPFLAGS@ @JSON_CPPFLAGS@ @SIGTOOL_CPPFLAGS@
 CLEANFILES = *.gcda *.gcno
 all: all-am
 
diff --git a/unit_tests/valgrind.supp b/unit_tests/valgrind.supp
--- a/unit_tests/valgrind.supp
+++ b/unit_tests/valgrind.supp
@@ -86,3 +86,16 @@
     ...
     fun:SSL_library_init
 }
+{
+   y0da-cached-virname
+   Memcheck:Cond
+   fun:cli_scanpe
+   fun:magic_scandesc
+   fun:cli_base_scandesc
+   fun:cli_magic_scandesc
+   fun:scan_common
+   fun:cl_scandesc_callback
+   fun:scanfile
+   fun:scanmanager
+   fun:main
+}

--- End Message ---
--- Begin Message ---
Version: 7.9

Hi,

These bugs relate to updates which were included in the 7.9 point
release.

Regards,

Adam

--- End Message ---

Reply to: