Browse code

Use BLOCKMAX

git-svn: trunk@2639

Nigel Horne authored on 2007/01/25 23:01:06
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Jan 25 14:00:27 GMT 2007 (njh)
2
+----------------------------------
3
+  * libclamav:	Use BLOCKMAX (suggestion from TK)
4
+
1 5
 Sat Jan 20 17:25:40 GMT 2007 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/mbox.c:	Fix bug 240, based on a patch from Edwin
... ...
@@ -16,7 +16,7 @@
16 16
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 17
  *  MA 02110-1301, USA.
18 18
  */
19
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.371 2007/01/20 17:24:44 njh Exp $";
19
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.372 2007/01/25 13:59:56 njh Exp $";
20 20
 
21 21
 #ifdef	_MSC_VER
22 22
 #include <winsock.h>	/* only needed in CL_EXPERIMENTAL */
... ...
@@ -2042,16 +2042,20 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re
2042 2042
 
2043 2043
 	cli_dbgmsg("in parseEmailBody\n");
2044 2044
 
2045
-	if(mctx->ctx->limits->maxmailrec)
2045
+	if(mctx->ctx->limits->maxmailrec) {
2046
+		const cli_ctx *ctx = mctx->ctx;	/* needed for BLOCKMAX :-( */
2047
+
2046 2048
 		/*
2047 2049
 		 * This is approximate
2048 2050
 		 */
2049
-		if(recursion_level > mctx->ctx->limits->maxmailrec) {
2051
+		if(BLOCKMAX &&
2052
+		  (recursion_level > ctx->limits->maxmailrec)) {
2050 2053
 			cli_warnmsg("parseEmailBody: hit maximum recursion level (%u)\n",
2051 2054
 				recursion_level);
2052
-			*mctx->ctx->virname = "MIME.RecursionLimit";
2055
+			*ctx->virname = "MIME.RecursionLimit";
2053 2056
 			return VIRUS;
2054 2057
 		}
2058
+	}
2055 2059
 
2056 2060
 	/* Anything left to be parsed? */
2057 2061
 	if(mainMessage && (messageGetBody(mainMessage) != NULL)) {
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: pdf.c,v 1.57 2007/01/19 19:47:54 njh Exp $";
18
+static	char	const	rcsid[] = "$Id: pdf.c,v 1.58 2007/01/25 13:59:56 njh Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -416,7 +416,7 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
416 416
 	nbytes = 0;
417 417
 
418 418
 	for(;;) {
419
-		zstat = inflate(&stream, Z_NO_FLUSH);
419
+		zstat = inflate(&stream, Z_NO_FLUSH);	/* zlib */
420 420
 		switch(zstat) {
421 421
 			case Z_OK:
422 422
 				if(stream.avail_out == 0) {
... ...
@@ -439,10 +439,10 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
439 439
 				break;
440 440
 			default:
441 441
 				if(stream.msg)
442
-					cli_warnmsg("After writing %u bytes, got error \"%s\" inflating PDF attachment\n",
442
+					cli_warnmsg("pdf: after writing %u bytes, got error \"%s\" inflating PDF attachment\n",
443 443
 						nbytes, stream.msg);
444 444
 				else
445
-					cli_warnmsg("After writing %u bytes, got error %d inflating PDF attachment\n",
445
+					cli_warnmsg("pdf: after writing %u bytes, got error %d inflating PDF attachment\n",
446 446
 						nbytes, zstat);
447 447
 				inflateEnd(&stream);
448 448
 				return zstat;
... ...
@@ -460,6 +460,7 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
460 460
 
461 461
 	if(ctx->limits &&
462 462
 	   ctx->limits->maxratio &&
463
+	   BLOCKMAX &&
463 464
 	   ((stream.total_out / stream.total_in) > ctx->limits->maxratio)) {
464 465
 		cli_dbgmsg("cli_pdf: flatedecode Max ratio reached\n");
465 466
 		inflateEnd(&stream);