Skip to content

Commit

Permalink
put invalid question name in error
Browse files Browse the repository at this point in the history
  • Loading branch information
xerbalind committed Aug 23, 2024
1 parent 4261d06 commit 60ea5f1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions zns/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ impl Message {
}

pub fn check_authoritative(&self, auth_zone: &LabelString) -> Result<(), ZNSError> {
let authoritative = self.question.iter().all(|question| {
for question in &self.question {
let zlen = question.qname.len();
zlen >= auth_zone.len()
&& vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone)
});

if !authoritative {
return Err(ZNSError::Refused {
message: "Not authoritative".to_string(),
});
if !(zlen >= auth_zone.len()
&& vec_equal(&question.qname[zlen - auth_zone.len()..], auth_zone))
{
return Err(ZNSError::Refused {
message: format!("Not authoritative for: {}", question.qname.join(".")),
});
}
}

Ok(())
}
}
Expand Down

0 comments on commit 60ea5f1

Please sign in to comment.