Skip to content

Commit d534bc7

Browse files
committed
dns.NewMsg can return nil on unsupported query types
1 parent 9c4d40c commit d534bc7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

dnscrypt-proxy/resolve.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func resolveQuery(server string, qName string, qType uint16, sendClientSubnet bo
2424
transport.ReadTimeout = 2 * time.Second
2525
client := &dns.Client{Transport: transport}
2626
msg := dns.NewMsg(qName, qType)
27+
if msg == nil {
28+
return nil, fmt.Errorf("unsupported DNS record type: %d", qType)
29+
}
2730
msg.RecursionDesired = true
2831
msg.Opcode = dns.OpcodeQuery
2932
msg.UDPSize = uint16(MaxDNSPacketSize)

dnscrypt-proxy/xtransport.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ func (xTransport *XTransport) resolveUsingResolver(
474474
defer cancel()
475475
for _, rrType := range queryType {
476476
msg := dns.NewMsg(fqdn(host), rrType)
477+
if msg == nil {
478+
continue
479+
}
477480
msg.RecursionDesired = true
478481
msg.UDPSize = uint16(MaxDNSPacketSize)
479482
msg.Security = true

0 commit comments

Comments
 (0)