File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -140,11 +140,9 @@ func parseAllowedIPs(ipns *[]netip.Prefix) func(ad *netlink.AttributeDecoder) er
140140 // Allowed IP nested attributes.
141141 ad .Nested (func (nad * netlink.AttributeDecoder ) error {
142142 var (
143- ipn netip.Addr
144- mask int
145- // TODO: we already have the family stored in ipn, is this needed?
143+ ipn netip.Addr
144+ mask int
146145 family int
147- _ = family
148146 )
149147
150148 for nad .Next () {
@@ -162,6 +160,19 @@ func parseAllowedIPs(ipns *[]netip.Prefix) func(ad *netlink.AttributeDecoder) er
162160 return err
163161 }
164162
163+ switch family {
164+ case unix .AF_INET :
165+ if ! ipn .Is4 () {
166+ return fmt .Errorf ("decoded IP address does not match the address family" )
167+ }
168+ case unix .AF_INET6 :
169+ if ! ipn .Is6 () {
170+ return fmt .Errorf ("decoded IP address does not match the address family" )
171+ }
172+ default :
173+ return fmt .Errorf ("invalid IP address family" )
174+ }
175+
165176 ipp := netip .PrefixFrom (ipn , mask )
166177
167178 * ipns = append (* ipns , ipp )
You can’t perform that action at this time.
0 commit comments