libspf dns bug while debugging enabled

Robert Story <[email protected]> Fri, 8 Jan 2010 12:25:05 -0500
Newsgroups gmane.mail.spam.spf.devel,gmane.spam.detected
Organization SPARTA
Message-ID <[email protected]>
--Sig_/jRnKqIMc6yBGgQ_r.m/Gf4Z
Content-Type: multipart/mixed; boundary="MP_/gfs7SGnSvMV/ltdxoiK29VZ"


--MP_/gfs7SGnSvMV/ltdxoiK29VZ
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

I kept getting failures while trying to run the command line utilities
with debugging enabled. A little poking around revealed a bug in
SPF_dns_resolv_lookup(), where the num_rr count was reset during the proces=
sing of other sections besides the answer section if debugging was on. This=
 would result in a NO_DATA herrno, even if data was found. I've attached a =
patch against 1.2.9 that works for me...


[Note: I tried sending the patch to the RT list, as suggested on the
web site, but it appears that the alias is broken:

   ----- Transcript of session follows -----
... while talking to pink.anarres.org.:
>>> DATA=20=20
<<< 550 unknown user
550 5.1.1 <[email protected]>... User unknown
]


--=20
Robert Story
Senior Software Engineer
SPARTA (dba Cobham Analytic Soloutions)



-------------------------------------------
Sender Policy Framework: http://www.openspf.org [http://www.openspf.org]
Modify Your Subscription: http://www.listbox.com/member/ [http://www.listbo=
x.com/member/]

Archives: https://www.listbox.com/member/archive/1007/=3Dnow
RSS Feed: https://www.listbox.com/member/archive/rss/1007/
Powered by Listbox: http://www.listbox.com

--MP_/gfs7SGnSvMV/ltdxoiK29VZ
Content-Type: text/x-patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=libspf2-debug.patch

--- src/libspf2/spf_dns_resolv.c.orig	2010-01-08 10:33:22.228944089 -0500
+++ src/libspf2/spf_dns_resolv.c	2010-01-08 10:27:17.678772774 -0500
@@ -381,6 +381,7 @@
 	}
=20
=20
+	spfrr->num_rr =3D 0;
 	/* FIXME  the error handling from here on is suspect at best */
 	for (ns_sect =3D 0; ns_sect < num_ns_sect; ns_sect++) {
 		/* We pass this point if:
@@ -396,7 +397,6 @@
 		if (spf_dns_server->debug > 1)
 			SPF_debugf("%s:  %d", ns_sects[ns_sect].name, nrec);
=20
-		spfrr->num_rr =3D 0;
 		cnt =3D 0;
 		for (i =3D 0; i < nrec; i++) {
 			err =3D ns_parserr(&ns_handle, ns_sects[ns_sect].number, i, &rr);
@@ -590,7 +590,8 @@
 			}
 		}
=20
-		spfrr->num_rr =3D cnt;
+		if (ns_sects[ns_sect].number =3D=3D ns_s_an) /* ignore other sections (s=
een during debugging) */
+			spfrr->num_rr =3D cnt;
 	}
=20
 	if (spfrr->num_rr =3D=3D 0)

--MP_/gfs7SGnSvMV/ltdxoiK29VZ--

--Sig_/jRnKqIMc6yBGgQ_r.m/Gf4Z
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)

iEYEARECAAYFAktHanYACgkQ7/fVLLY1mnhqsQCfXf5yQuQdqcd8k2Uz83g1ZzAl
om0An0Mfp6oHzYyoqQz5Fqz9kH9RBfUU
=s8bz
-----END PGP SIGNATURE-----

--Sig_/jRnKqIMc6yBGgQ_r.m/Gf4Z--