summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-12-02 10:56:39 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-02-10 17:18:05 +0900
commit100253c7f0f4d105ae88340a0314506cde69cfd2 (patch)
tree2e839fd73cb3452aadc3be865baaf68cd24aef79 /lib
parent5221cb4468526a18875c21cff5dee5ac96d9873b (diff)
[ruby/ipaddr] Ipaddr#native must also coerce `@mask_addr`
Before it would be left as an IPv6 mask causing `to_range` to fail. ``` >> IPAddr.new("::2").native.to_range /opt/rubies/3.0.3/lib/ruby/3.0.0/ipaddr.rb:479:in `set': invalid address (IPAddr::InvalidAddressError) ``` https://github.com/ruby/ipaddr/commit/af485192f3
Diffstat (limited to 'lib')
-rw-r--r--lib/ipaddr.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 9cc210c307..51ad081e23 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -510,6 +510,9 @@ class IPAddr
@addr = addr
if family[0]
@family = family[0]
+ if @family == Socket::AF_INET
+ @mask_addr &= IN4MASK
+ end
end
return self
end