openbsd spamd is leaking memory?

Bob Beck beck at ualberta.ca
Wed Feb 25 08:23:35 PST 2009



* Max Laier <max at love2party.net> [2009-02-25 06:43]:
> Hello Artis,
> 
> looks like a valid catch to me.  I'm CC'ing the upstream maintainer (Bob, 
> that's you, right?)  From a quick glance there is also a minor leak in 
> readsuffixlists in the goto bad case.

	Yeah you're right max, in fact there are three possibilities for 
a slow leak.. try this:

Index: grey.c
===================================================================
RCS file: /cvs/src/libexec/spamd/grey.c,v
retrieving revision 1.45
diff -u grey.c
--- grey.c	7 Dec 2008 21:12:52 -0000	1.45
+++ grey.c	25 Feb 2009 15:46:09 -0000
@@ -315,8 +315,11 @@
 	size_t len;
 	struct mail_addr *m;
 
-	while (!SLIST_EMPTY(&match_suffix))
+	while (!SLIST_EMPTY(&match_suffix)) {
+		m = SLIST_FIRST(&match_suffix);	  
 		SLIST_REMOVE_HEAD(&match_suffix, entry);
+		free(m);
+	}
 	if ((fp = fopen(alloweddomains_file, "r")) != NULL) {
 		while ((buf = fgetln(fp, &len))) {
 			if (buf[len-1] == '\n')
@@ -337,8 +340,11 @@
 	}
 	return;
 bad:
-	while (!SLIST_EMPTY(&match_suffix))
+	while (SLIST_EMPTY(&match_suffix)) {
+	  	m = SLIST_FIRST(&match_suffix);
 		SLIST_REMOVE_HEAD(&match_suffix, entry);
+		free(m);
+	}
 }
 
 void
@@ -512,6 +518,7 @@
 		dbc->act = 0;
 		dbc->dsiz = 0;
 		SLIST_REMOVE_HEAD(&db_changes, entry);
+		free(dbc);
 
 	}
 	return(ret);


More information about the freebsd-pf mailing list