Browse code

Increase the chance of a stack trace being printed

git-svn: trunk@3258

Nigel Horne authored on 2007/10/01 19:35:02
Showing 2 changed files
... ...
@@ -1,3 +1,9 @@
1
+Mon Oct  1 10:52:13 BST 2007 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Increase the chance of a stack trace being printed in
4
+				the event of trouble.
5
+			Various compiler warnings removed.
6
+
1 7
 Sun Sep 30 23:18:11 EEST 2007 (edwin)
2 8
 -------------------------------------
3 9
   * libclamav/phishcheck.c, regex_list.c: more improvements to the algorithm.
... ...
@@ -24,12 +30,12 @@ Wed Sep 26 23:36:06 CEST 2007 (tk)
24 24
 Tue Sep 25 10:43:35 BST 2007 (njh)
25 25
 ----------------------------------
26 26
   * libclamav/mbox.c:	Only use strcasestr on Linux (for now, until it
27
-  				can be built into configure)
27
+				can be built into configure)
28 28
 
29 29
 Sun Sep 23 13:49:12 BST 2007 (njh)
30 30
 ----------------------------------
31 31
   * libclamav/mbox.c:	MailFollowURLS: Prefer .exes for download, catches
32
-  				Trojan.IRC-Script-33
32
+				Trojan.IRC-Script-33
33 33
 
34 34
 Sat Sep 22 18:14:49 EEST 2007 (edwin)
35 35
 -------------------------------------
... ...
@@ -43,7 +49,7 @@ Fri Sep 21 18:40:56 EEST 2007 (edwin)
43 43
 Fri Sep 21 00:33:37 CEST 2007 (acab)
44 44
 ------------------------------------
45 45
   * libclamav/pe.c: Avoid variadic macroes make vc6 happy. Big thx to
46
-  			Gianluigi Tiesi for reporting and testing.
46
+			Gianluigi Tiesi for reporting and testing.
47 47
 
48 48
 Fri Sep 21 00:18:08 EEST 2007(edwin)
49 49
 ------------------------------------
... ...
@@ -4005,8 +4005,8 @@ do_checkURLs(const char *dir, tag_arguments_t *hrefs)
4005 4005
 	 * downloaded and scanned
4006 4006
 	 */
4007 4007
 	for(i = FOLLOWURLS; (i < hrefs->count) && (n < FOLLOWURLS); i++) {
4008
-		const char *url = (const char *)hrefs->value[i];
4009
-		const char *ptr;
4008
+		char *url = (char *)hrefs->value[i];
4009
+		char *ptr;
4010 4010
 
4011 4011
 		if(strncasecmp("http://", url, 7) != 0)
4012 4012
 			continue;
... ...
@@ -4017,9 +4017,9 @@ do_checkURLs(const char *dir, tag_arguments_t *hrefs)
4017 4017
 		if(strcasecmp(ptr, ".exe") == 0) {
4018 4018
 			/* FIXME: Could be swapping with another .exe */
4019 4019
 			cli_dbgmsg("swap %s %s\n", hrefs->value[n], hrefs->value[i]);
4020
-			ptr = hrefs->value[n];
4021
-			hrefs->value[n++] = url;
4022
-			hrefs->value[i] = ptr;
4020
+			ptr = (char *)hrefs->value[n];
4021
+			hrefs->value[n++] = (unsigned char *)url;
4022
+			hrefs->value[i] = (unsigned char *)ptr;
4023 4023
 		}
4024 4024
 	}
4025 4025
 
... ...
@@ -4643,21 +4643,25 @@ print_trace(int use_syslog)
4643 4643
 	size_t i;
4644 4644
 	pid_t pid = getpid();
4645 4645
 
4646
+	cli_errmsg("Segmentation fault, attempting to print backtrace\n");
4647
+
4646 4648
 	size = backtrace(array, 10);
4647 4649
 	strings = backtrace_symbols(array, size);
4648 4650
 
4649
-	if(use_syslog == 0)
4650
-		cli_dbgmsg("Backtrace of pid %d:\n", pid);
4651
-	else
4651
+	cli_errmsg("Backtrace of pid %d:\n", pid);
4652
+	if(use_syslog)
4652 4653
 		syslog(LOG_ERR, "Backtrace of pid %d:", pid);
4653 4654
 
4654
-	for(i = 0; i < size; i++)
4655
+	for(i = 0; i < size; i++) {
4656
+		cli_errmsg("%s\n", strings[i]);
4655 4657
 		if(use_syslog)
4656 4658
 			syslog(LOG_ERR, "bt[%u]: %s", i, strings[i]);
4657
-		else
4658
-			cli_dbgmsg("%s\n", strings[i]);
4659
+	}
4659 4660
 
4660
-	/* TODO: dump the current email */
4661
+#ifdef	SAVE_TMP
4662
+	cli_errmsg("The errant mail file has been saved\n");
4663
+#endif
4664
+	/* #else TODO: dump the current email */
4661 4665
 
4662 4666
 	free(strings);
4663 4667
 }
... ...
@@ -4769,6 +4773,8 @@ isBounceStart(const char *line)
4769 4769
 	   (memcmp(line, ">From ", 6) == 0)) {
4770 4770
 		int numSpaces = 0, numDigits = 0;
4771 4771
 
4772
+		line += 4;
4773
+
4772 4774
 		do
4773 4775
 			if(*line == ' ')
4774 4776
 				numSpaces++;