Browse code

Bug 698

git-svn: trunk@3338

Nigel Horne authored on 2007/10/31 01:31:51
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Oct 30 15:40:49 GMT 2007 (njh)
2
+----------------------------------
3
+  * libclamav/pdf.c:	Bug 698
4
+
1 5
 Mon Oct 29 20:27:36 EET 2007 (edwin)
2 6
 ------------------------------------
3 7
   * libclamav/phishcheck.c: better handling for \n
... ...
@@ -79,11 +79,11 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
79 79
 	char *buf, *alloced;	/* start of memory mapped area */
80 80
 	const char *p, *q, *trailerstart;
81 81
 	const char *xrefstart;	/* cross reference table */
82
+	const struct cl_limits *limits;
82 83
 	/*size_t xreflength;*/
83
-	int rc = CL_CLEAN;
84 84
 	table_t *md5table;
85
-	int printed_predictor_message;
86
-	int printed_embedded_font_message;
85
+	int printed_predictor_message, printed_embedded_font_message, rc;
86
+	unsigned int files;
87 87
 	struct stat statb;
88 88
 
89 89
 	cli_dbgmsg("in cli_pdf(%s)\n", dir);
... ...
@@ -210,6 +210,10 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
210 210
 	bytesleft -= xreflength;
211 211
 	 */
212 212
 
213
+	rc = CL_CLEAN;
214
+	files = 0;
215
+	limits = ctx->limits;
216
+
213 217
 	/*
214 218
 	 * The body section consists of a sequence of indirect objects
215 219
 	 */
... ...
@@ -429,6 +433,7 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
429 429
 		if(streamend <= streamstart) {
430 430
 			close(fout);
431 431
 			cli_dbgmsg("Empty stream\n");
432
+			unlink(fullname);
432 433
 			continue;
433 434
 		}
434 435
 		calculated_streamlen = (int)(streamend - streamstart);
... ...
@@ -510,7 +515,13 @@ cli_pdf(const char *dir, int desc, const cli_ctx *ctx)
510 510
 		} else
511 511
 			tableInsert(md5table, md5digest, 1);
512 512
 		free(md5digest);
513
-		cli_dbgmsg("cli_pdf: extracted to %s\n", fullname);
513
+		cli_dbgmsg("cli_pdf: extracted file %d to %s\n", ++files,
514
+			fullname);
515
+		if(limits && limits->maxfiles && (files >= limits->maxfiles)) {
516
+			/* Bug 698 */
517
+			cli_dbgmsg("cli_pdf: number of files exceeded %u\n", limits->maxfiles);
518
+			break;
519
+		}
514 520
 	}
515 521
 
516 522
 	if(alloced)