Subversion Repositories

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

Rev 24 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
9 magnus 1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 42_empty_sender.dpatch by  <magnus@proffe.kibibyte.se>
3
##
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: If SPF_request_set_env_from() is called with from set to the empty
6
## DP: string, use the HELO identity. Also fix incorrect handling when
7
## DP: the local part is empty (but the "@" is present).
8
 
9
@DPATCH@
10
diff -urNad trunk~/src/libspf2/spf_request.c trunk/src/libspf2/spf_request.c
11
--- trunk~/src/libspf2/spf_request.c	2005-02-22 03:38:57.000000000 +0100
12
+++ trunk/src/libspf2/spf_request.c	2007-07-30 21:58:48.000000000 +0200
13
@@ -142,14 +142,19 @@
14
 	SPF_FREE(sr->env_from_lp);
15
 	SPF_FREE(sr->env_from_dp);
16
 
17
+	if (*from == '\0' && sr->helo_dom != NULL) {
18
+		from = sr->helo_dom;
19
+	}
20
 	cp = strrchr(from, '@');
21
 	if (cp && (cp != from)) {
22
 		sr->env_from = strdup(from);
23
-		sr->env_from_lp = strdup(from);	/* Too long, but simple */
24
-		sr->env_from_lp[(cp - from)] = '\0';
25
+		*cp = '\0';
26
+		sr->env_from_lp = strdup(from);
27
 		sr->env_from_dp = strdup(cp + 1);
28
+		*cp = '@';
29
 	}
30
 	else {
31
+		if (cp == from) from++; /* "@domain.example" */
32
 		len = sizeof("postmaster@") + strlen(from);
33
 		sr->env_from = malloc(len + 1);	/* sizeof("") == 1? */
34
 		sprintf(sr->env_from, "postmaster@%s", from);