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

Shevek <[email protected]> Tue, 04 Nov 2008 16:31:34 +0000
Newsgroups gmane.mail.spam.spf.devel
Message-ID <1225816294.26965.44.camel@localhost>
On Thu, 2008-10-30 at 02:39 +0900, Hajimu UMEMOTO wrote:
> Hi,
> 
> >>>>> On Mon, 27 Oct 2008 14:52:15 +0100
> >>>>> Hannah Schroeter <[email protected]> said:
> 
> >@@ -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;
> > 	}
> 
> hannah> Why is that needed, and how portable is that in fact, compared to
> hannah> calling res_init unconditionally in that place?
> 
> Because, the libspf2 is not only consumer of the resolver.  The
> res_init() might be called already before calling it from libspf2.  It
> is enough to call res_init() once.
> Basically, res_init() is used in this manner on BSDs.  The impact of
> calling res_init() again and again is unclear.
> I'm not sure about portability, but the _res and RES_INIT is described
> in resolver(8) on at least BSDs and CentOS.

I do not believe we are allowed to look inside _res. I have certainly
included the patch for res_ndestroy, but I believe the library authors
have to make calling res_init() multiple times safe. Perhaps you could
check this in your system source code? I have checked two
implementations, including the one at
http://www.koders.com/c/fid6F05A2EABB6A6CFB02D691F0F98DFB676F0B15E7.aspx?s=sort#L212 and both appear safe.

Please see 1.2.9. Further patches will make 1.2.10 in a week or two.

S.