Skip to content

Commit

Permalink
Fix undefined cname race condition
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Dubois <jan@jandubois.com>
  • Loading branch information
dee-kryvenko and jandubois authored Oct 20, 2021
1 parent dbc04dc commit 19ebfb6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/hostagent/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
switch q.Qtype {
case dns.TypeCNAME, dns.TypeA, dns.TypeAAAA:
cname, err := net.LookupCNAME(q.Name)
if err == nil && cname != "" && cname != q.Name {
if err != nil {
break
}
if cname != "" && cname != q.Name {
hdr.Rrtype = dns.TypeCNAME
a := &dns.CNAME{
Hdr: hdr,
Expand Down

0 comments on commit 19ebfb6

Please sign in to comment.