Browse code

Added debug statements

git-svn: trunk@2635

Nigel Horne authored on 2007/01/20 04:49:08
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Jan 19 19:48:29 GMT 2007 (njh)
2
+----------------------------------
3
+  * libclamav/pdf.c:	Improved error messages
4
+
1 5
 Wed Jan 17 20:50:45 GMT 2007 (njh)
2 6
 ----------------------------------
3 7
   * clamav-milter:	Fix -I core dump, reported by Dennis Peterson
... ...
@@ -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.56 2006/10/22 10:23:26 njh Exp $";
18
+static	char	const	rcsid[] = "$Id: pdf.c,v 1.57 2007/01/19 19:47:54 njh Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -171,7 +171,9 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
171 171
 	/*
172 172
 	 * The body section consists of a sequence of indirect objects
173 173
 	 */
174
-	while((p < xrefstart) && ((q = pdf_nextobject(p, bytesleft)) != NULL)) {
174
+	while((p < xrefstart) &&
175
+	      ((q = pdf_nextobject(p, bytesleft)) != NULL) &&
176
+	      (rc == CL_CLEAN)) {
175 177
 		int is_ascii85decode, is_flatedecode, fout, len;
176 178
 		/*int object_number, generation_number;*/
177 179
 		const char *objstart, *objend, *streamstart, *streamend;
... ...
@@ -361,8 +363,11 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
361 361
 
362 362
 			if(zstat != Z_OK)
363 363
 				rc = CL_EZIP;
364
-		} else
364
+		} else {
365
+			cli_dbgmsg("cli_pdf: writing %u bytes from the stream\n",
366
+				streamlen);
365 367
 			cli_writen(fout, (char *)streamstart, streamlen);
368
+		}
366 369
 
367 370
 		close(fout);
368 371
 		md5digest = cli_md5file(fullname);
... ...
@@ -423,9 +428,7 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
423 423
 					   (nbytes > (off_t) ctx->limits->maxfilesize)) {
424 424
 						cli_dbgmsg("cli_pdf: flatedecode size exceeded (%lu)\n", nbytes);
425 425
 						inflateEnd(&stream);
426
-#ifdef	notdef
427 426
 						*ctx->virname = "PDF.ExceededFileSize";
428
-#endif
429 427
 						return Z_DATA_ERROR;
430 428
 					}
431 429
 					stream.next_out = output;
... ...
@@ -436,9 +439,11 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
436 436
 				break;
437 437
 			default:
438 438
 				if(stream.msg)
439
-					cli_warnmsg("Error \"%s\" inflating PDF attachment\n", stream.msg);
439
+					cli_warnmsg("After writing %u bytes, got error \"%s\" inflating PDF attachment\n",
440
+						nbytes, stream.msg);
440 441
 				else
441
-					cli_warnmsg("Error %d inflating PDF attachment\n", zstat);
442
+					cli_warnmsg("After writing %u bytes, got error %d inflating PDF attachment\n",
443
+						nbytes, zstat);
442 444
 				inflateEnd(&stream);
443 445
 				return zstat;
444 446
 		}
... ...
@@ -458,9 +463,7 @@ flatedecode(const unsigned char *buf, size_t len, int fout, const cli_ctx *ctx)
458 458
 	   ((stream.total_out / stream.total_in) > ctx->limits->maxratio)) {
459 459
 		cli_dbgmsg("cli_pdf: flatedecode Max ratio reached\n");
460 460
 		inflateEnd(&stream);
461
-#ifdef	notdef
462 461
 		*ctx->virname = "Oversized.PDF";
463
-#endif
464 462
 		return Z_DATA_ERROR;
465 463
 	}
466 464