aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-09 12:27:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-09 12:27:57 +0000
commitf7daba4edf1dc6f6653a934327e2a072b314ad90 (patch)
treefd3d8dda43e72e90b7a2d4ddbba6fe3766e7b50f /src
parentee027014127ed66e8fb874fde244cda8fc065daf (diff)
downloadrspamd-f7daba4edf1dc6f6653a934327e2a072b314ad90.tar.gz
rspamd-f7daba4edf1dc6f6653a934327e2a072b314ad90.zip
[Minor] Fix length calculations
Diffstat (limited to 'src')
-rw-r--r--src/libserver/spf.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/libserver/spf.c b/src/libserver/spf.c
index 1766ef64e..14881697e 100644
--- a/src/libserver/spf.c
+++ b/src/libserver/spf.c
@@ -1812,16 +1812,36 @@ expand_spf_macro (struct spf_record *rec, struct spf_resolved_element *resolved,
len += INET6_ADDRSTRLEN - 1;
break;
case 's':
- len += strlen (rec->sender);
+ if (rec->sender) {
+ len += strlen (rec->sender);
+ }
+ else {
+ len += sizeof ("unknown") - 1;
+ }
break;
case 'l':
- len += strlen (rec->local_part);
+ if (rec->local_part) {
+ len += strlen (rec->local_part);
+ }
+ else {
+ len += sizeof ("unknown") - 1;
+ }
break;
case 'o':
- len += strlen (rec->sender_domain);
+ if (rec->sender_domain) {
+ len += strlen (rec->sender_domain);
+ }
+ else {
+ len += sizeof ("unknown") - 1;
+ }
break;
case 'd':
- len += strlen (resolved->cur_domain);
+ if (resolved->cur_domain) {
+ len += strlen (resolved->cur_domain);
+ }
+ else {
+ len += sizeof ("unknown") - 1;
+ }
break;
case 'v':
len += sizeof ("in-addr") - 1;
@@ -1830,6 +1850,9 @@ expand_spf_macro (struct spf_record *rec, struct spf_resolved_element *resolved,
if (task->helo) {
len += strlen (task->helo);
}
+ else {
+ len += sizeof ("unknown") - 1;
+ }
break;
default:
msg_info_spf (