Browse code

Further empty line optimisation

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@629 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/06/24 01:25:08
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Wed Jun 23 17:23:59 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Further optimisation in the handling of empty lines
4
+  	in emails
5
+
1 6
 Wed Jun 23 15:16:20 BST 2004 (trog)
2 7
 -----------------------------------
3 8
   * libclamav/ole2_extract.c: fix possible mmap overrun.
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.80  2004/06/23 16:23:25  nigelhorne
21
+ * Further empty line optimisation
22
+ *
20 23
  * Revision 1.79  2004/06/22 04:08:01  nigelhorne
21 24
  * Optimise empty lines
22 25
  *
... ...
@@ -225,7 +228,7 @@
225 225
  * Compilable under SCO; removed duplicate code with message.c
226 226
  *
227 227
  */
228
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.79 2004/06/22 04:08:01 nigelhorne Exp $";
228
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.80 2004/06/23 16:23:25 nigelhorne Exp $";
229 229
 
230 230
 #if HAVE_CONFIG_H
231 231
 #include "clamav-config.h"
... ...
@@ -583,7 +586,10 @@ parseEmailHeaders(const message *m, const table_t *rfc821Table)
583 583
 			buffer = strdup(t->t_text);
584 584
 			if(buffer == NULL)
585 585
 				break;
586
-			cli_chomp(buffer);
586
+			if(cli_chomp(buffer) == 0) {
587
+				free(buffer);
588
+				buffer = NULL;
589
+			}
587 590
 		} else
588 591
 			buffer = NULL;
589 592
 
... ...
@@ -614,7 +620,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821Table)
614 614
 			 * A blank line signifies the end of the header and
615 615
 			 * the start of the text
616 616
 			 */
617
-			if((buffer == NULL) || (strlen(buffer) == 0)) {
617
+			if(buffer == NULL) {
618 618
 				cli_dbgmsg("End of header information\n");
619 619
 				inContinuationHeader = inHeader = FALSE;
620 620
 			} else if(parseEmailHeader(ret, buffer, rfc821Table) == CONTENT_TYPE)
... ...
@@ -824,11 +830,9 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con
824 824
 				 * but some viruses insert them
825 825
 				 */
826 826
 				while((t_line = t_line->t_next) != NULL)
827
-					if(t_line->t_text) {
828
-						cli_chomp(t_line->t_text);
829
-						if(strlen(t_line->t_text) != 0)
830
-							break;
831
-					}
827
+					if(t_line->t_text &&
828
+					   (cli_chomp(t_line->t_text) > 0))
829
+						break;
832 830
 
833 831
 				if(t_line == NULL) {
834 832
 					cli_dbgmsg("Empty part\n");