kazu-yamamoto / iproute

IP Routing Table in Haskell
http://www.mew.org/~kazu/proj/iproute/
BSD 3-Clause "New" or "Revised" License
47 stars 28 forks source link

Check that IPv4 addresses terminate #63

Closed coot closed 4 months ago

coot commented 4 months ago

The existing parser admits 0.0.0.0. to be parsed as a valid IPv4 address, while it isn't.

kazu-yamamoto commented 4 months ago

Merged and a new version has been released. Thanks!

coot commented 4 months ago

Thanks @kazu-yamamoto.

When I talked with my team, some people suggested not parsing white space, but this could have wild consequences for downstream users - hence, I preserved it. However, I checked that inet_pton on Linux, doesn't parse white space on either side.

Hmm, I just realized that by admitting trailing white space, we allow this to parse 0.0.0.0 /32, which is also wrong.

> read "0.0.0.0 /32" :: IPRange
0.0.0.0/32

I'll create a PR to fix this.

vdukhovni commented 3 weeks ago

Sadly, this PR also broke parsing of IPv6 ranges with embedded IPv4 addresses. The range "::ffff:0.0.0.0/96" no longer parses, because the termination check in parsing embedded addresses objects to the "/96".