[PATCH] libspf2/spf_request.c: Fix handling of email addresses in query_rcptto().

Florian Forster <[email protected]> Sun, 23 Jan 2011 15:47:53 +0100
Newsgroups gmane.mail.spam.spf.devel
Message-ID <1b9d778db159c5df8774b5fd960f79d5be0404ad.1295793984.git.ff@octo.it>
From: Florian Forster <[email protected]>

The function SPF_request_query_rcptto() checks whether the "rcpt_to"
string argument contains the "@" character. If so, everything before the
at-sign is stripped. However, the at-sign itself left in front of the
string, so that the generated SPF record reads:

    v=spf1 mx:@example.com

The actual checking code then tries to resolve "@example.com" rather than
"example.com", fails and returns "neutral" even when it should return
"pass".

This patch adds the missing `rcpt_to_dom++` so the at-sign is stripped,
too.
---
 src/libspf2/spf_request.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/libspf2/spf_request.c b/src/libspf2/spf_request.c
index 7614141..b502fb2 100644
--- a/src/libspf2/spf_request.c
+++ b/src/libspf2/spf_request.c
@@ -363,6 +363,8 @@ SPF_request_query_rcptto(SPF_request_t *spf_request,
 	rcpt_to_dom = strchr(rcpt_to, '@');
 	if (rcpt_to_dom == NULL)
 		rcpt_to_dom = rcpt_to;
+	else
+		rcpt_to_dom++;
 	spf_request->cur_dom = rcpt_to_dom;
 
 	len = sizeof(SPF_VER_STR) + 64 + strlen(rcpt_to_dom);
-- 
1.7.2.3