Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

IPAddr.new accepts certain IPv6 literals when AF_INET is specified

Open
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
ruby
Domain
networking

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.

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"
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dominant language
Ruby
Stars
82
Forks
42
Avg merge
2h 24m
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/ipaddr

All issues in ruby/ipaddr

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.