layeh / radius

a Go (golang) RADIUS client and server implementation
https://pkg.go.dev/layeh.com/radius
Mozilla Public License 2.0
571 stars 181 forks source link

Unable to get IPv6 with prefix from Framed-IPv6-Prefix attribute #118

Closed dav-komarek closed 10 months ago

dav-komarek commented 10 months ago

Description

When packet containing following bytes is parsed 61 0a 00 40 20 01 15 30 10 0e using rfc3162.FramedIPv6Prefix_Get, the error is returned in the inner function radius.IPv6Prefix on the line https://github.com/layeh/radius/blob/master/attribute.go#L471. But the provided IPv6 is valid address (2001:1530:100e::/64)

Proposal

The function radius.IPv6Prefix should be able to parse IPv6 of the specified format.

Apparently the check for the length of the byte array (linked) is wrong and should be replaced with check that the prefix is at most 128 bits long.

u873838 commented 10 months ago

Should be fixed with 1006025d24f8fdd5b5ee8b3c15a714e6b24baaab.

dav-komarek commented 10 months ago

Please check https://github.com/layeh/radius/commit/1006025d24f8fdd5b5ee8b3c15a714e6b24baaab#r134862652.