Re: Fwd: [milter-greylist] HEADS-UP: libspf2 causes milter-greylist memory leak?

Hajimu UMEMOTO <[email protected]> Sat, 25 Oct 2008 01:48:32 +0900
Newsgroups gmane.mail.spam.spf.devel
Organization Internet Mutual Aid Society, YOKOHAMA
Message-ID <yge1vy6q6qn.wl%[email protected]>
Hi,

>>>>> On Fri, 24 Oct 2008 18:02:36 +0200
>>>>> Fredrik Pettai <[email protected]> said:

pettai> This has been fixed by a patch in the FreeBSD Ports tree. See (and specifically
pettai> patch submission [2]):
pettai> ftp://ftp.freebsd.org/pub/FreeBSD/development/FreeBSD-CVS/ports/mail/libspf2/files/patch-src_libspf2_spf__dns__resolv.c,v

pettai> AFAICS, this fix doesn't seem to be in the latest version of the libspf2-1.2.8
pettai> source. Maybe someone can add it to libspf2's main CVS branch instead?

Here is a patch against 1.2.8:

Index: src/libspf2/spf_dns_resolv.c
diff -u -p src/libspf2/spf_dns_resolv.c.orig src/libspf2/spf_dns_resolv.c
--- src/libspf2/spf_dns_resolv.c.orig	Thu Oct 16 07:02:03 2008
+++ src/libspf2/spf_dns_resolv.c	Fri Oct 24 12:19:29 2008
@@ -92,7 +92,11 @@ static pthread_key_t	res_state_key;
 static void
 SPF_dns_resolv_thread_term(void *arg)
 {
+#ifdef res_ndestroy
+	res_ndestroy( (struct __res_state *)arg );
+#else
 	res_nclose( (struct __res_state *)arg );
+#endif
 	free(arg);
 }
 
@@ -615,7 +619,7 @@ SPF_dns_resolv_new(SPF_dns_server_t *lay
 #if HAVE_DECL_RES_NINIT
 	pthread_once(&res_state_control, SPF_dns_resolv_init_key);
 #else
-	if ( res_init() != 0 ) {
+	if ((_res.options & RES_INIT) == 0 && res_init() != 0) {
 		perror("res_init");
 		return NULL;
 	}


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
[email protected]  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/