Bug 1298282 - Fix IPv6 addresses in URIs with Net::HTTP
Summary: Fix IPv6 addresses in URIs with Net::HTTP
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ruby
Version: 7.2
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Pavel Valena
QA Contact: Iveta Wiedermann
URL:
Whiteboard:
Depends On:
Blocks: 1313485 1289025 1295829
TreeView+ depends on / blocked
 
Reported: 2016-01-13 16:18 UTC by Tomas Jelinek
Modified: 2018-11-21 12:54 UTC (History)
7 users (show)

Fixed In Version: ruby-2.0.0.648-26.el7
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2016-11-04 06:16:24 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2016:2422 normal SHIPPED_LIVE ruby bug fix update 2016-11-03 13:59:14 UTC
Ruby 9129 None None None 2016-05-19 11:05:11 UTC
Red Hat Bugzilla 1197720 None None None Never

Internal Links: 1197720

Description Tomas Jelinek 2016-01-13 16:18:04 UTC
Description of problem:
There is a bug in ruby stdlib Net::HTTP class which prevents connecting to hosts using IPv6.


Version-Release number of selected component (if applicable):
[root@rh72-node1:~]# ruby -v
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
[root@rh72-node1:~]# rpm -q ruby
ruby-2.0.0.598-25.el7_1.x86_64


How reproducible:
easily, always


Steps to Reproduce:
[root@rh72-node1:~]# irb
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> myhttp = Net::HTTP.new("::1")
=> #<Net::HTTP ::1:80 open=false>
irb(main):003:0> myhttp.start
URI::InvalidURIError: the scheme http does not accept registry part: ::1:80 (or bad hostname?)
        from /usr/share/ruby/uri/generic.rb:214:in `initialize'
        from /usr/share/ruby/uri/http.rb:84:in `initialize'
        from /usr/share/ruby/uri/common.rb:214:in `new'
        from /usr/share/ruby/uri/common.rb:214:in `parse'
        from /usr/share/ruby/uri/common.rb:747:in `parse'
        from /usr/share/ruby/uri/common.rb:996:in `URI'
        from /usr/share/ruby/net/http.rb:1027:in `proxy_uri'
        from /usr/share/ruby/net/http.rb:1014:in `proxy?'
        from /usr/share/ruby/net/http.rb:868:in `connect'
        from /usr/share/ruby/net/http.rb:862:in `do_start'
        from /usr/share/ruby/net/http.rb:857:in `start'
        from (irb):3
        from /usr/bin/irb:12:in `<main>'
irb(main):004:0> myhttp = Net::HTTP.new("[::1]")
=> #<Net::HTTP [::1]:80 open=false>
irb(main):005:0> myhttp.start
SocketError: getaddrinfo: Name or service not known
        from /usr/share/ruby/net/http.rb:878:in `initialize'
        from /usr/share/ruby/net/http.rb:878:in `open'
        from /usr/share/ruby/net/http.rb:878:in `block in connect'
        from /usr/share/ruby/timeout.rb:52:in `timeout'
        from /usr/share/ruby/net/http.rb:877:in `connect'
        from /usr/share/ruby/net/http.rb:862:in `do_start'
        from /usr/share/ruby/net/http.rb:857:in `start'
        from (irb):5
        from /usr/bin/irb:12:in `<main>'
irb(main):006:0>


Actual results:
Ruby does not even try to connect to localhost no matter if the address is enclosed in [] (which is wrong anyways) or not.


Expected results:
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> myhttp = Net::HTTP.new("::1")
=> #<Net::HTTP ::1:80 open=false>
irb(main):003:0> myhttp.start
Errno::ECONNREFUSED: Connection refused - connect(2) for "::1" port 80
        from /usr/share/ruby/net/http.rb:879:in `initialize'
        from /usr/share/ruby/net/http.rb:879:in `open'
        from /usr/share/ruby/net/http.rb:879:in `block in connect'
        from /usr/share/ruby/timeout.rb:73:in `timeout'
        from /usr/share/ruby/net/http.rb:878:in `connect'
        from /usr/share/ruby/net/http.rb:863:in `do_start'
        from /usr/share/ruby/net/http.rb:858:in `start'
        from (irb):3
        from /usr/bin/irb:11:in `<main>'
irb(main):004:0>

Ruby tries to connect to localhost. Since there is no HTTP server running, it gets Errno::ECONNREFUSED, that is not an issue.


Additional info:
This has been reported in upstream https://bugs.ruby-lang.org/issues/9129
and fixed as well https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47079

Comment 2 Vít Ondruch 2016-01-14 11:23:13 UTC
This could be resolved by rebase of Ruby 2.0.0 I am proposing in bug 1197720.

Comment 7 errata-xmlrpc 2016-11-04 06:16:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHEA-2016-2422.html


Note You need to log in before you can comment on or make changes to this bug.