]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix length calculations
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Dec 2019 12:27:57 +0000 (12:27 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 9 Dec 2019 12:27:57 +0000 (12:27 +0000)
src/libserver/spf.c

index 1766ef64e8b2f45e9af5f6186ac616e1dabb2b2a..14881697e025b001102f609c7a2c8353f13c0828 100644 (file)
@@ -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 (