Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,13 @@ fn presented_ip_address_matches_constraint(
let mut name = untrusted::Reader::new(name);
let mut constraint_address = untrusted::Reader::new(constraint_address);
let mut constraint_mask = untrusted::Reader::new(constraint_mask);
let (mut mask_index, mut mask) = (0, [0u8; 8]);
loop {
let name_byte = name.read_byte().unwrap();
let constraint_address_byte = constraint_address.read_byte().unwrap();
let constraint_mask_byte = constraint_mask.read_byte().unwrap();
mask[mask_index] = constraint_mask_byte;
mask_index += 1;
if ((name_byte ^ constraint_address_byte) & constraint_mask_byte) != 0 {
return Ok(false);
}
Expand All @@ -375,6 +378,11 @@ fn presented_ip_address_matches_constraint(
}
}

let mask = u64::from_be_bytes(mask);
if mask.trailing_zeros() != 64 - mask.count_ones() {
return Ok(false);
}

return Ok(true);
}

Expand Down