$OpenBSD: patch-src_libspf2_spf_request_c,v 1.1.1.1 2008/01/30 15:58:50 okan Exp $ --- src/libspf2/spf_request.c.orig Mon Feb 21 21:38:57 2005 +++ src/libspf2/spf_request.c Thu Jan 24 23:06:21 2008 @@ -142,14 +142,19 @@ SPF_request_set_env_from(SPF_request_t *sr, const char SPF_FREE(sr->env_from_lp); SPF_FREE(sr->env_from_dp); + if (*from == '\0' && sr->helo_dom != NULL) { + from = sr->helo_dom; + } cp = strrchr(from, '@'); if (cp && (cp != from)) { sr->env_from = strdup(from); - sr->env_from_lp = strdup(from); /* Too long, but simple */ - sr->env_from_lp[(cp - from)] = '\0'; + *cp = '\0'; + sr->env_from_lp = strdup(from); sr->env_from_dp = strdup(cp + 1); + *cp = '@'; } else { + if (cp == from) from++; /* "@domain.example" */ len = sizeof("postmaster@") + strlen(from); sr->env_from = malloc(len + 1); /* sizeof("") == 1? */ sprintf(sr->env_from, "postmaster@%s", from); @@ -306,6 +311,9 @@ SPF_request_query_rcptto(SPF_request_t *spf_request, const char *rcpt_to_dom; char *record; size_t len; + + if ( (spf_request == NULL) || (rcpt_to == NULL) ) + return SPF_E_INVALID_OPT; SPF_ASSERT_NOTNULL(spf_request); spf_server = spf_request->spf_server;