]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Require either by or from parts in received headers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Oct 2021 12:18:37 +0000 (13:18 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 8 Oct 2021 12:18:37 +0000 (13:18 +0100)
src/libmime/received.cxx

index 0ff52da5a793e81aee6bc82dae76f44f1611927d..6ba2cd678a8d34f125efbeb6628289f2453858e3 100644 (file)
@@ -253,6 +253,7 @@ received_spill(const std::string_view &in,
 {
        std::vector<received_part> parts;
        std::ptrdiff_t pos = 0;
+       auto seen_from = false, seen_by = false;
 
        const auto *p = in.data();
        const auto *end = p + in.size();
@@ -289,6 +290,7 @@ received_spill(const std::string_view &in,
                g_assert (pos != 0);
                p += pos;
                len = end > p ? end - p : 0;
+               seen_from = true;
        }
 
        if (len > 2 && lit_compare_lowercase<2>("by", p)) {
@@ -301,6 +303,12 @@ received_spill(const std::string_view &in,
                g_assert (pos != 0);
                p += pos;
                len = end > p ? end - p : 0;
+               seen_by = true;
+       }
+
+       if (!seen_from && !seen_by) {
+               /* Useless received */
+               return {};
        }
 
        while (p < end) {