From 3378f966a03efca33ede9ddcb0f25a9d57a3ccb4 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Wed, 3 Apr 2024 15:42:41 +0200 Subject: [PATCH] Check PTR against FQDN (including dot at the end) (closes #28) --- resources/spf/basic.yml | 2 +- src/spf/verify.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/spf/basic.yml b/resources/spf/basic.yml index 57ea3ab..a00787c 100644 --- a/resources/spf/basic.yml +++ b/resources/spf/basic.yml @@ -96,7 +96,7 @@ records: spf: ptr.test.org v=spf1 ptr:test.org -all mx: mx.test.org 10.0.0.1,10.0.0.2,10.0.0.3,10.0.0.4,10.0.0.5,10.0.0.6,10.0.0.7,10.0.0.8,10.0.0.9,10.0.0.10,10.0.0.11 ptr: 10.0.0.1 h1.test.org - ptr: 10.0.0.11 h1.test.org, h2.test.org, h3.test.org, h4.test.org, h5.test.org, h6.test.org, h7.test.org, h8.test.org, h9.test.org, h10.test.org, h11.test.org + ptr: 10.0.0.11 h1.test.org, h2.test.org., h3.test.org., h4.test.org, h5.test.org, h6.test.org, h7.test.org, h8.test.org, h9.test.org, h10.test.org, h11.test.org a: h1.test.org 10.0.0.1 a: h11.test.org 10.0.0.11 tests: diff --git a/src/spf/verify.rs b/src/spf/verify.rs index b781a02..22842b8 100644 --- a/src/spf/verify.rs +++ b/src/spf/verify.rs @@ -269,7 +269,10 @@ impl Resolver { self.ip_matches(record, ip, u32::MAX, u128::MAX).await { matches = record == &target_addr - || record.ends_with(&target_sub_addr); + || record + .strip_suffix('.') + .unwrap_or(record.as_str()) + .ends_with(&target_sub_addr); if matches { break; }