socketry/rubydns

Resolv::DNS::DecodeError: limit exceeded

Closed this issue · 1 comments

I've written a really simple rubydns server and put it online to check how it is working. After some time the server stopped to respond with this error:

rubydns@web1:~/rubydns$ ./server.rb
 0.03s     info: Starting Async::DNS server (v1.2.5)... [pid=14308] [2020-04-17 14:11:44 +0200]
 0.03s     info: <> Listening for datagrams on #<Addrinfo: 0.0.0.0:5300 UDP> [pid=14308] [2020-04-17 14:11:44 +0200]
 0.03s     info: <> Listening for connections on #<Addrinfo: 0.0.0.0:5300 TCP> [pid=14308] [2020-04-17 14:11:44 +0200]
 40m9s    error: Async::DNS::DatagramHandler [oid=0x398] [pid=14308] [2020-04-17 14:51:53 +0200]
               |   Resolv::DNS::DecodeError: limit exceeded
               |   → /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1604 in `get_string'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1652 in `get_label'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1646 in `get_labels'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1619 in `get_name'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1656 in `get_question'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1528 in `block (2 levels) in decode'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1527 in `each'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1527 in `block in decode'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1552 in `initialize'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1516 in `new'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/resolv.rb:1516 in `decode'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/async/dns/message.rb:43 in `decode_message'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/async/dns/handler.rb:58 in `process_query'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/async/dns/handler.rb:82 in `respond'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/async/dns/handler.rb:76 in `block in run'
               |     /home/rubydns/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/async-1.24.2/lib/async/task.rb:258 in `block in make_fiber'

As the request to my server came from an other DNS server, I can't reproduce it simply. There was already a bug #10 which is similar to this. Maybe you can have a look.

Found an issue in an other project: slack-ruby/slack-ruby-client#66 but it's very old.

I've tried to find an according entry in ruby issue tracker but couldn't find one.

Gemfile.lock as reference:

GEM
  remote: https://rubygems.org/
  specs:
    async (1.24.2)
      console (~> 1.0)
      nio4r (~> 2.3)
      timers (~> 4.1)
    async-dns (1.2.5)
      async-io (~> 1.15)
    async-io (1.28.0)
      async (~> 1.14)
    console (1.8.2)
    minitest (5.14.0)
    nio4r (2.5.2)
    rubydns (2.0.2)
      async-dns (~> 1.0)
    timers (4.3.0)

PLATFORMS
  ruby

DEPENDENCIES
  minitest
  rubydns

BUNDLED WITH
   2.1.4

Running the same code with ruby 2.6.6 fixes the problem. I'll close this issue and create an issue on ruby tracker after investigating the changes between versions.