From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id CE6B119C0021 for ; Thu, 29 Oct 2015 06:33:56 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 1E816B5D8DB for ; Thu, 29 Oct 2015 07:01:56 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 0F1AE952408 for ; Thu, 29 Oct 2015 07:01:55 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C047A1204C1; Thu, 29 Oct 2015 07:01:53 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8A631120457 for ; Thu, 29 Oct 2015 07:01:49 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=bQZ985sQh/W/N7cbPjPxBelw2Ls=; b=kKhc9loOezHk1gU4Y5 lHwe88dxY9tuo25q4HvZ9QuldyD+3oln7/du6ISdkCTPReu+0tO63alGeNnvbloA YV9xhziqrVtkHsVSFz0jrQ7k/G8i5S6crSKaZTdl7D4lKaAtQKcfKb5uzoJBm6Cz wsr9N4Erk2e9ohqG5WqSn6g9o= Received: by filter0896p1mdw1.sendgrid.net with SMTP id filter0896p1mdw1.14682.563145C82B 2015-10-28 22:01:44.592289039 +0000 UTC Received: from herokuapp.com (ec2-54-81-127-246.compute-1.amazonaws.com [54.81.127.246]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id -oPgaZRYRsyCAOpA--ruwQ for ; Wed, 28 Oct 2015 22:01:44.522 +0000 (UTC) Date: Wed, 28 Oct 2015 22:01:44 +0000 From: hannes.georg@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45884 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11632 X-Redmine-Issue-Author: hannes.georg X-Redmine-Sender: hannes.georg X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7sn9gLYbemX0X6L6iTujyDHYARdjenkzcHxj tZCNPok9CCNi2MXpRAP8D2smHhuRg5WKL875vP7GKfsaNx+zMiAxTEZ90e3k/QyF2swzU92G13QWVT YvMNhVJ3RhlyrSMS+hgGvbCB7tTj92AZiMS/ X-SendGrid-Contentd-ID: {"test_id":"1446069705"} X-ML-Name: ruby-core X-Mail-Count: 71255 Subject: [ruby-core:71255] [Ruby trunk - Bug #11632] Resolv::DNS::Message.encode fails to encode messages larger than 16383 byte X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11632 has been updated by Hannes Georg. I've created a small script to demonstrate the behavior. The following script should print "test" but it prints some gibberish bytes in ruby 2.1.7 and 2.2.3. ~~~ require 'resolv' msg = Resolv::DNS::Message.new # this generates ~ 17000 bytes 500.times.each do |i| msg.add_answer("abcdefghijklmn%04d." % i,300,Resolv::DNS::Resource::IN::A.new("0.0.0.0")) end msg.add_answer("test.",300,Resolv::DNS::Resource::IN::A.new("0.0.0.0")) msg.add_answer("test.",300,Resolv::DNS::Resource::IN::A.new("0.0.0.0")) encoded = msg.encode decoded = Resolv::DNS::Message.decode(encoded) puts decoded.answer.last[0].to_s.inspect ~~~ ---------------------------------------- Bug #11632: Resolv::DNS::Message.encode fails to encode messages larger than 16383 byte https://bugs.ruby-lang.org/issues/11632#change-54627 * Author: Hannes Georg * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- Hello Rubyists The ruby dns message encoder automatically remembers _all_ label addresses to be reused later ( see https://github.com/ruby/ruby/blob/v2_2_3/lib/resolv.rb#L1470 ). The address field however is limited to 14 bits ( see https://tools.ietf.org/html/rfc1035#section-4.1.4 ). If the message gets larger than 16383 bytes the addresses of new labels won't fit anymore. The encoder takes this into account and truncates the addresses on write which makes them invalid ( see https://github.com/ruby/ruby/blob/v2_2_3/lib/resolv.rb#L1467 ). My suggested solution is to not store addresses larger than 16383. Is a github pr okay for that? -- https://bugs.ruby-lang.org/