IPAddr.new accepts certain IPv6 literals when AF_INET is specified
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 82
- Forks
- 42
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 3
Description
If the given address is an IPv6 literal enclosed in brackets and/or with a zone ID suffix, it will be unexpectedly accepted.
All the following invocations expect AddressFamilyError.
% bundle exec irb -ripaddr
irb(main):001:0> IPAddr.new('[::]', Socket::AF_INET)
=> #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0000/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
irb(main):002:0> IPAddr.new('::%eth0', Socket::AF_INET)
=> #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0000%eth0/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
irb(main):003:0> IPAddr.new('[::%eth0]', Socket::AF_INET)
=> #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0000%eth0/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
irb(main):004:0> IPAddr.new('::', Socket::AF_INET)
/.../ruby/ipaddr/lib/ipaddr.rb:633:in `initialize': address family mismatch (IPAddr::AddressFamilyError)
raise AddressFamilyError, "address family mismatch"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the listed IPAddr.new calls in irb with -ripaddr, then inspect ipaddr.rb around line 633 where AddressFamilyError is raised. The fix is done when bracketed or zone-ID IPv6 literals supplied with Socket::AF_INET raise AddressFamilyError like the plain IPv6 literal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100