commit f7daba4: [Minor] Fix length calculations
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Dec 9 12:35:07 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-12-09 12:27:57 +0000
URL: https://github.com/rspamd/rspamd/commit/f7daba4edf1dc6f6653a934327e2a072b314ad90
[Minor] Fix length calculations
---
src/libserver/spf.c | 31 +++++++++++++++++++++++++++----
1 file 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 (
More information about the Commits
mailing list