Skip to content

Commit

Permalink
Merge pull request #987 from thvdveld/fix-panic-when-dns
Browse files Browse the repository at this point in the history
Don't panic if no valid source address is found for the DNS query
  • Loading branch information
Dirbaio authored Sep 16, 2024
2 parents 749d8c7 + 115fd06 commit dee8975
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/socket/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,15 @@ impl<'a> Socket<'a> {
};

let dst_addr = servers[pq.server_idx];
let src_addr = cx.get_source_address(&dst_addr).unwrap(); // TODO remove unwrap
let src_addr = match cx.get_source_address(&dst_addr) {
Some(src_addr) => src_addr,
None => {
net_trace!("no source address for destination {}", dst_addr);
q.set_state(State::Failure);
continue;
}
};

let ip_repr = IpRepr::new(
src_addr,
dst_addr,
Expand Down

0 comments on commit dee8975

Please sign in to comment.