Commit
Author: Mauro D [mauro@stalw.art]
Hash: 5122a529485e1c30574433b1eee8e73ea1c2fb05
Timestamp: Tue, 13 Dec 2022 17:48:20 +0000 (1 year ago)

+2 -2 +/-1 browse
Fixed IP address mask matching.
1diff --git a/src/spf/verify.rs b/src/spf/verify.rs
2index e85dd4c..7655943 100644
3--- a/src/spf/verify.rs
4+++ b/src/spf/verify.rs
5 @@ -394,14 +394,14 @@ impl IpMask for IpAddr {
6 u32::from_be_bytes(match &self {
7 IpAddr::V4(ip) => ip.octets(),
8 IpAddr::V6(ip) => {
9- if let Some(ip) = ip.to_ipv4() {
10+ if let Some(ip) = ip.to_ipv4_mapped() {
11 ip.octets()
12 } else {
13 return false;
14 }
15 }
16 }) & mask
17- == u32::from_be_bytes(addr.octets())
18+ == u32::from_be_bytes(addr.octets()) & mask
19 }
20
21 fn matches_ipv6_mask(&self, addr: &Ipv6Addr, mask: u128) -> bool {