ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: lay20114@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92567] [Ruby trunk Bug#15832] IPAddr.new accepts invalid mask IP address
Date: Sun, 05 May 2019 20:52:29 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-15832.20190505205228.c84523e85b731f94@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15832.20190505205228@ruby-lang.org

Issue #15832 has been reported by tsuna (Kenta Tsuna).

----------------------------------------
Bug #15832: IPAddr.new accepts invalid mask IP address
https://bugs.ruby-lang.org/issues/15832

* Author: tsuna (Kenta Tsuna)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-05-05 trunk 594a033ff0) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
IPAddr.new accepts IP address with multiple mask and/or zero padded one.
```
$ cat ipaddr.rb
require 'ipaddr'

addrs = %w[192.0.2.0/24/16
           192.0.2.0/00024
           192.0.2.0/24/00016
           192.0.2.0/00024/16
           2001:db8::/32/24
           2001:db8::/00032
           2001:db8::/32/00024
           2001:db8::/00032/24]

addrs.each do |addr|
  begin
    p IPAddr.new(addr)
    puts "#{addr} is valid"
  rescue StandardError
    puts "#{addr} is invalid"
  end
end
```
```
$ ruby ipaddr.rb
#<IPAddr: IPv4:192.0.2.0/255.255.255.0>
192.0.2.0/24/16 is valid
#<IPAddr: IPv4:192.0.2.0/255.255.255.0>
192.0.2.0/00024 is valid
#<IPAddr: IPv4:192.0.2.0/255.255.255.0>
192.0.2.0/24/00016 is valid
#<IPAddr: IPv4:192.0.2.0/255.255.255.0>
192.0.2.0/00024/16 is valid
#<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0000/ffff:ffff:0000:0000:0000:0000:0000:0000>
2001:db8::/32/24 is valid
#<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0000/ffff:ffff:0000:0000:0000:0000:0000:0000>
2001:db8::/00032 is valid
#<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0000/ffff:ffff:0000:0000:0000:0000:0000:0000>
2001:db8::/32/00024 is valid
#<IPAddr: IPv6:2001:0db8:0000:0000:0000:0000:0000:0000/ffff:ffff:0000:0000:0000:0000:0000:0000>
2001:db8::/00032/24 is valid
```



-- 
https://bugs.ruby-lang.org/

       reply	other threads:[~2019-05-05 20:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15832.20190505205228@ruby-lang.org>
2019-05-05 20:52 ` lay20114 [this message]
2019-06-05  2:02 ` [ruby-core:92967] [Ruby trunk Bug#15832] IPAddr.new accepts invalid mask IP address merch-redmine
2019-07-09  6:55 ` [ruby-core:93630] [Ruby master " samuel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-15832.20190505205228.c84523e85b731f94@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).