diff options
author | Jeremy Evans <[email protected]> | 2021-03-08 15:28:04 -0800 |
---|---|---|
committer | git <[email protected]> | 2023-11-24 19:17:19 +0000 |
commit | 974d18fd0c13bd19120cad70187f5b646c901dff (patch) | |
tree | 7d694cc6a9556b339e44c60f2bb8980da38fa100 /lib/resolv.rb | |
parent | 269c705f93c4db631f4cad89991bc5d69a7dcd03 (diff) |
[ruby/resolv] Fix the fallback from UDP to TCP due to message truncation
If truncation is detected, return immediately from decode so that
the UDP connection can be retried with TCP, instead of failing to
decode due to trying to decode a truncated response.
Fixes [Bug #13513]
https://github.com/ruby/resolv/commit/0de996dbca
Diffstat (limited to 'lib/resolv.rb')
-rw-r--r-- | lib/resolv.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb index 0c96ee80b9..8203e5110a 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1520,13 +1520,15 @@ class Resolv id, flag, qdcount, ancount, nscount, arcount = msg.get_unpack('nnnnnn') o.id = id + o.tc = (flag >> 9) & 1 + o.rcode = flag & 15 + return o unless o.tc.zero? + o.qr = (flag >> 15) & 1 o.opcode = (flag >> 11) & 15 o.aa = (flag >> 10) & 1 - o.tc = (flag >> 9) & 1 o.rd = (flag >> 8) & 1 o.ra = (flag >> 7) & 1 - o.rcode = flag & 15 (1..qdcount).each { name, typeclass = msg.get_question o.add_question(name, typeclass) |