ameshkov / dnscrypt

DNSCrypt v2 protocol implementation + a command-line tool
The Unlicense
74 stars 14 forks source link

panic in client.go if stamp DNS response has no TXT records (and under other conditions) #18

Closed ainar-g closed 1 year ago

ainar-g commented 1 year ago

See AdguardTeam/AdGuardHome#5557. Client.DialStamp uses Client.fetchCert, which has bad error handling. certErr is overwritten on every iteration of the loop over r.Answer and is never set at all if there are no answers or if none of the answers are TXT. That results in Client.fetchCert returning nil, nil, which leads to a panic in Client.DialStamp.

Client.fetchCert has a cyclomatic complexity of 14 and a cognitive complexity of 23 and needs refactoring.