Skip to content

Commit

Permalink
bugfix: check data len for NSEC record
Browse files Browse the repository at this point in the history
  • Loading branch information
keepsimple1 committed Dec 18, 2024
1 parent 60db6f0 commit 422b441
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/dns_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,16 @@ impl DnsIncoming {
// o The Type Bit Map block length byte is a value in the range 1-32.
// o The Type Bit Map data is 1-32 bytes, as indicated by length
// byte.

// Sanity check: at least 2 bytes to read.
if self.data.len() < self.offset + 2 {
return Err(Error::Msg(format!(
"DnsIncoming is too short: {} at NSEC Type Bit Map offset {}",
self.data.len(),
self.offset
)));
}

let block_num = self.data[self.offset];
self.offset += 1;
if block_num != 0 {
Expand Down

0 comments on commit 422b441

Please sign in to comment.