Browse code

Fixed possible memory leak

git-svn: trunk@2145

Nigel Horne authored on 2006/07/30 19:10:40
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sun Jul 30 11:09:22 BST 2006 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Fixed (remote possibility) memory leak, reported
4
+				by Torok Edvin <edwintorok*gmail.com>
5
+
1 6
 Sun Jul 30 08:35:49 BST 2006 (njh)
2 7
 ---------------------------------
3 8
   * docs/man/clamav-milter.8:	Fix formatting errors and a typo
... ...
@@ -134,7 +139,7 @@ Mon Jul 17 11:40:14 CEST 2006 (tk)
134 134
 
135 135
 Mon Jul 17 03:00:21 CEST 2006 (acab)
136 136
 ------------------------------------
137
-  * libclamav/wwunpack.c: image size fixup 
137
+  * libclamav/wwunpack.c: image size fixup
138 138
 
139 139
 Mon Jul 17 01:17:40 CEST 2006 (acab)
140 140
 ------------------------------------
... ...
@@ -748,7 +753,7 @@ Fri Jan 14 14:51:01 CET 2006 (acab)
748 748
 ---------------------------------
749 749
   * libclamav: added yC support
750 750
 		thanks a lot to Ivan Zlatev <pumqara*gmail.com>
751
-  
751
+
752 752
 Fri Jan 13 14:53:45 CET 2006 (tk)
753 753
 ---------------------------------
754 754
   * libclamav/vba_extract.c: fix possible memory leak, reported by  Cesar
... ...
@@ -940,7 +945,7 @@ Sun Oct 30 18:46:36 CET 2005 (tk)
940 940
 
941 941
 Mon Oct 24 12:29:31 CEST 2005 (acab)
942 942
 ------------------------------------
943
-  * libclamav/pe.c: fixed possible infinite loop, reported by Christoph 
943
+  * libclamav/pe.c: fixed possible infinite loop, reported by Christoph
944 944
 
945 945
 Thu Oct 20 00:54:13 CEST 2005 (tk)
946 946
 ----------------------------------
... ...
@@ -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.325 2006/07/25 15:09:45 njh Exp $";
19
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.326 2006/07/30 10:08:39 njh Exp $";
20 20
 
21 21
 #if HAVE_CONFIG_H
22 22
 #include "clamav-config.h"
... ...
@@ -2388,8 +2388,13 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx)
2388 2388
 			cli_dbgmsg("The message has %d parts\n", multiparts);
2389 2389
 
2390 2390
 			if(((multiparts == 0) || infected) && (aText == NULL)) {
2391
-				if(messages)
2391
+				if(messages) {
2392
+					for(i = 0; i < multiparts; i++)
2393
+						if(messages[i])
2394
+							messageDestroy(messages[i]);
2392 2395
 					free(messages);
2396
+				}
2397
+
2393 2398
 				/*
2394 2399
 				 * FIXME: we could return 2 here when we have
2395 2400
 				 * saved stuff earlier
... ...
@@ -2675,8 +2680,11 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx)
2675 2675
 			break;
2676 2676
 		}
2677 2677
 
2678
-		if(messages)
2678
+		if(messages) {
2679
+			/* "can't happen" */
2680
+			cli_warnmsg("messages != NULL, report to bugs@clamav.net\n");
2679 2681
 			free(messages);
2682
+		}
2680 2683
 	}
2681 2684
 
2682 2685
 	if(aText && (textIn == NULL)) {
... ...
@@ -4423,10 +4431,8 @@ do_multipart(message *mainMessage, message **messages, int i, int *rc, mbox_ctx
4423 4423
 			messages[i] = NULL;
4424 4424
 #else
4425 4425
 			/*
4426
-			 * Scan in memory, faster but
4427
-			 * is open to DoS attacks when
4428
-			 * many nested levels are
4429
-			 * involved.
4426
+			 * Scan in memory, faster but is open to DoS attacks
4427
+			 * when many nested levels are involved.
4430 4428
 			 */
4431 4429
 			body = parseEmailHeaders(aMessage, mctx->rfc821Table,
4432 4430
 				TRUE);
... ...
@@ -4533,8 +4539,7 @@ next_is_folded_header(const text *t)
4533 4533
 	data = lineGetData(next->t_line);
4534 4534
 
4535 4535
 	/*
4536
-	 * Section B.2 of RFC822 says TAB or
4537
-	 * SPACE means a continuation of the
4536
+	 * Section B.2 of RFC822 says TAB or SPACE means a continuation of the
4538 4537
 	 * previous entry.
4539 4538
 	 */
4540 4539
 	if(isblank(data[0]))