Open Tietew opened 2 years ago
I was unable to reproduce this error in the current master of resolv and Ruby 3.2.
The error is caused by a failure to read the length of TCP message so it looks related to TCP fallback, but is not the same problem as #6, which fails to decode the truncated UDP message.
As the dig
result shows SERVER: 127.0.0.53#53(127.0.0.53)
, the direct nameserver seems to be systemd-resolved's stub listener. IIRC, it had bugs regarding truncation or TCP fallback in the past (I can't find the exact report or fix, but https://github.com/systemd/systemd/pull/6988 may be related).
The reported exception suggests that the TCP socket was closed before sending the message length, and resolv does't handle such a protocol violation. Here we need to check if read(2)
actually returns 2 octets:
https://github.com/ruby/resolv/blob/b25c63cf7cef2b298a47634fcb50ae1ec288d7df/lib/resolv.rb#L899-L903
Reproducible code
Expected result:
Returns TXT records (see below)
Actual result:
Current TXT records of
google.com