Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 24 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/bin/sh /usr/share/dpatch/dpatch-run
## 42_empty_sender.dpatch by Magnus Holmgren <magnus@kibibyte.se>
##
## DP: If SPF_request_set_env_from() is called with from set to the empty
## DP: string (i.e. a DSN), use the HELO identity. Also fix incorrect
## DP: handling when the local part is empty (but the "@" is present).

@DPATCH@
diff -urNad trunk~/src/libspf2/spf_request.c trunk/src/libspf2/spf_request.c
--- trunk~/src/libspf2/spf_request.c    2005-02-22 03:38:57.000000000 +0100
+++ trunk/src/libspf2/spf_request.c     2007-07-30 21:58:48.000000000 +0200
@@ -142,14 +142,19 @@
        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);