Browse code

libclamav/pdf.c: fix write error with specific files (bb#1181)

git-svn: trunk@4173

Tomasz Kojm authored on 2008/09/12 04:42:38
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Sep 11 21:46:48 CEST 2008 (tk)
2
+----------------------------------
3
+  * libclamav/pdf.c: fix write error with specific files (bb#1181)
4
+
1 5
 Thu Sep 11 13:16:22 EEST 2008 (edwin)
2 6
 -------------------------------------
3 7
   * build system: allow 'make check' to work even if check is not installed
... ...
@@ -401,13 +401,15 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx, off_t offset)
401 401
 		calculated_streamlen = (int)(streamend - streamstart);
402 402
 		real_streamlen = length;
403 403
 
404
-		if(calculated_streamlen != real_streamlen)
405
-			cli_dbgmsg("cli_pdf: Incorrect Length field in file attempting to recover\n");
406
-
407 404
 		cli_dbgmsg("cli_pdf: length %lu, calculated_streamlen %lu isFlate %d isASCII85 %d\n",
408 405
 			length, calculated_streamlen,
409 406
 			is_flatedecode, is_ascii85decode);
410 407
 
408
+		if(calculated_streamlen != real_streamlen) {
409
+			cli_dbgmsg("cli_pdf: Incorrect Length field in file attempting to recover\n");
410
+			if(real_streamlen > calculated_streamlen)
411
+				real_streamlen = calculated_streamlen;
412
+		}
411 413
 #if	0
412 414
 		/* FIXME: this isn't right... */
413 415
 		if(length)