summarylogtreecommitdiffstats
path: root/fixes-1.5.9.diff
blob: 7966b1caf609c5e426868df06b354fc5a1027588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index fdd4a5136..d985695fc 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -1386,7 +1386,7 @@ reverse_spf_ip (gchar *ip, gint len)
 }
 
 static const gchar *
-expand_spf_macro (struct spf_record *rec,
+expand_spf_macro (struct spf_record *rec, struct spf_resolved_element *resolved,
 		const gchar *begin)
 {
 	const gchar *p;
@@ -1396,13 +1396,11 @@ expand_spf_macro (struct spf_record *rec,
 	gchar ip_buf[INET6_ADDRSTRLEN];
 	gboolean need_expand = FALSE;
 	struct rspamd_task *task;
-	struct spf_resolved_element *resolved;
 
 	g_assert (rec != NULL);
 	g_assert (begin != NULL);
 
 	task = rec->task;
-	resolved = g_ptr_array_index (rec->resolved, rec->resolved->len - 1);
 	p = begin;
 	/* Calculate length */
 	while (*p) {
@@ -1594,8 +1592,14 @@ expand_spf_macro (struct spf_record *rec,
 						c += len;
 						break;
 					case 'v':
-						len = sizeof ("in-addr") - 1;
-						memcpy (c, "in-addr", len);
+						if (rspamd_inet_address_get_af (task->from_addr) == AF_INET) {
+							len = sizeof ("in-addr") - 1;
+							memcpy (c, "in-addr", len);
+						}
+						else {
+							len = sizeof ("ip6") - 1;
+							memcpy (c, "ip6", len);
+						}
 						c += len;
 						break;
 					case 'h':
@@ -1606,6 +1610,11 @@ expand_spf_macro (struct spf_record *rec,
 								memcpy (c, tmp + 1, len);
 								c += len;
 							}
+							else {
+								len = strlen (task->helo);
+								memcpy (c, task->helo, len);
+								c += len;
+							}
 						}
 						break;
 					default:
@@ -1671,7 +1680,7 @@ parse_spf_record (struct spf_record *rec, struct spf_resolved_element *resolved,
 	}
 
 	task = rec->task;
-	begin = expand_spf_macro (rec, elt);
+	begin = expand_spf_macro (rec, resolved, elt);
 	addr = rspamd_spf_new_addr (rec, resolved, begin);
 	g_assert (addr != NULL);
 	t = g_ascii_tolower (addr->spf_string[0]);
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 75f4091b8..f5471eee4 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -944,7 +944,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
 		fuzzy_module_ctx->text_multiplier = ucl_object_todouble (value);
 	}
 	else {
-		fuzzy_module_ctx->text_multiplier = 0.5;
+		fuzzy_module_ctx->text_multiplier = 2.0;
 	}
 
 	if ((value =
@@ -2319,11 +2319,12 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 			/* Check length of part */
 			fac = fuzzy_module_ctx->text_multiplier * part->content->len;
 			if ((double)fuzzy_module_ctx->min_bytes > fac) {
-				msg_info_task ("<%s>, part is shorter than %d bytes (%.0f * %.2f bytes), "
+				msg_info_task ("<%s>, part is shorter than %d bytes: %.0f "
+						"(%d * %.2f bytes), "
 						"skip fuzzy check",
 						task->message_id, fuzzy_module_ctx->min_bytes, fac,
-						fuzzy_module_ctx->text_multiplier,
-						part->content->len);
+						part->content->len,
+						fuzzy_module_ctx->text_multiplier);
 				continue;
 			}