Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make correct mask when converting IPv4 <=> IPv6 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Tietew
Copy link

@Tietew Tietew commented Jun 24, 2019

When converting IPv4 to/from IPv6, IPAddr#set generates incorrect mask value.
This causes IPAddr#include? returns incorrect result.

ip4 = IPAddr.new('::ffff:127.0.0.1').native
p [ip4.to_s, ip4.prefix]
ip6 = IPAddr.new('127.0.0.1').ipv4_mapped
p [ip6.to_s, ip6.prefix]

Expected

["127.0.0.1", 32]
["::ffff:127.0.0.1", 128]

Actual

["127.0.0.1", -96]       # @mask_addr == 0xFFFFFFFFFFFFFFFF
["::ffff:127.0.0.1", 0]  # @mask_addr == 0x000000000000FFFF

@ioquatix ioquatix requested a review from hsbt June 24, 2019 11:50
@ioquatix ioquatix added the bug label Jun 24, 2019
@ioquatix ioquatix self-assigned this Jun 24, 2019
@hsbt hsbt requested review from knu and removed request for hsbt June 25, 2019 00:39
@ioquatix
Copy link
Member

ioquatix commented Jul 9, 2019

@Tietew can you rebase on master.

@Tietew
Copy link
Author

Tietew commented Jul 10, 2019

@ioquatix done.

@ioquatix
Copy link
Member

Can you please squash typo fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

2 participants