changeset 674:a81c74ff2995

Added more sanity checks (Thomas Jarosch)
author mortenp
date Sat, 01 Nov 2008 01:20:51 +1100
parents d0a7bd17f13d
children 2f98510cc11a
files ChangeLog src/mlmmj-bounce.c src/mlmmj-maintd.c src/mlmmj-send.c src/strgen.c
diffstat 5 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 01 01:09:56 2008 +1100
+++ b/ChangeLog	Sat Nov 01 01:20:51 2008 +1100
@@ -1,3 +1,4 @@
+ o Added more sanity checks (Thomas Jarosch)
  o Disabled digest mails when 'noarchive' is set (Thomas Jarosch)
  o Added Russian listtexts (Nikolay Derkach)
  o Fixed mmap()ing of zero-sized files (Robin H. Johnson)
--- a/src/mlmmj-bounce.c	Sat Nov 01 01:09:56 2008 +1100
+++ b/src/mlmmj-bounce.c	Sat Nov 01 01:20:51 2008 +1100
@@ -92,6 +92,7 @@
 	 		continue;
 
 		colon = strchr(line, ':');
+		MY_ASSERT(colon);
 		*colon = '\0';
 		s = indexstr;
 		indexstr = concatstr(4, s, "        ", line, "\n");
@@ -320,6 +321,7 @@
 			exit(EXIT_SUCCESS);
 
 		a = strrchr(address, '@');
+		MY_ASSERT(a);
 		*a = '=';
 	}
 
--- a/src/mlmmj-maintd.c	Sat Nov 01 01:09:56 2008 +1100
+++ b/src/mlmmj-maintd.c	Sat Nov 01 01:20:51 2008 +1100
@@ -245,6 +245,7 @@
 
 		if(strchr(dp->d_name, '.')) {
 			ch = strrchr(mailname, '.');
+			MY_ASSERT(ch);
 			*ch = '\0';
 			if(stat(mailname, &st) < 0) {
 				if(errno == ENOENT) {
--- a/src/mlmmj-send.c	Sat Nov 01 01:09:56 2008 +1100
+++ b/src/mlmmj-send.c	Sat Nov 01 01:20:51 2008 +1100
@@ -1067,6 +1067,7 @@
 			/* error, so remove the probefile */
 			tmpstr = mystrdup(to_addr);
 			a = strchr(tmpstr, '@');
+			MY_ASSERT(a);
 			*a = '=';
 			probefile = concatstr(4, listdir, "/bounce/", tmpstr,
 					"-probe");
--- a/src/strgen.c	Sat Nov 01 01:09:56 2008 +1100
+++ b/src/strgen.c	Sat Nov 01 01:20:51 2008 +1100
@@ -32,9 +32,11 @@
 #include <ctype.h>
 #include <errno.h>
 
+#include "mlmmj.h"
 #include "strgen.h"
 #include "wrappers.h"
 #include "memory.h"
+#include "log_error.h"
 
 char *random_str()
 {
@@ -57,6 +59,7 @@
 	snprintf(tmpstr, len, "%s", addr);
 
 	atsign = strchr(tmpstr, '@');
+	MY_ASSERT(atsign);
 	*atsign = '=';
 
 	snprintf(dest, len, "%x%x-%s", random_int(), random_int(), tmpstr);
@@ -82,6 +85,7 @@
 	char *dest, *atsign;
 
 	atsign = strchr(listaddr, '@');
+	MY_ASSERT(atsign);
 	len = atsign - listaddr + 1;
 	dest = mymalloc(len);
 	
@@ -96,6 +100,7 @@
 	char *dest, *atsign;
 
 	atsign = strchr(listaddr, '@');
+	MY_ASSERT(atsign);
 	len = strlen(listaddr) - (atsign - listaddr);
 	dest = mymalloc(len);
 	snprintf(dest, len, "%s", atsign + 1);
@@ -143,9 +148,9 @@
 
 	for (;;) {
 		len *= 2;
-		free(hostname);
+		myfree(hostname);
 
-		hostname = malloc(len);
+		hostname = mymalloc(len);
 		hostname[len-1] = '\0';
 
 		/* gethostname() is allowed to:
@@ -278,7 +283,7 @@
 	const char *weekday = NULL, *month = NULL;
 
 	/* 6 + 26 + ' ' + timezone which is 5 + '\n\0' == 40 */
-	timestr = (char *)malloc(40);
+	timestr = (char *)mymalloc(40);
 	t = time(NULL);
 
 	localtime_r(&t, &lttm);