jdresolve
jdresolve copied to clipboard
Retrying truncated UDP queries over TCP leads to discrepancies in the $socks{$fileno} hash...
I stumbled upon a crash that I hunted down to echo '196.29.35.79' | jdresolve --debug=3 --timeout=10 -
.
I can see in my improved debug the trace that freesocket uses a different $fileno than the corresponding query. The tcpdump trace shows an UDP query and a subsequent TCP query. This specific IP address resolves to 34 names...
My solution was to add $res->igntc(1);
just after the resolver instanciation, which prevents TCP retries and the added socket:
347 my $res = new Net::DNS::Resolver; # used for sending dns requests
348 $res->igntc(1); # If true, truncated packets will be ignored. If false, the query will be retried using TCP.
349 my $sel = new IO::Select; # controls the open sockets