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

ipaddress.reverse_pointer returns nonsense if prefixed input is given #91601

Open
Zugschlus opened this issue Apr 16, 2022 · 0 comments
Open

ipaddress.reverse_pointer returns nonsense if prefixed input is given #91601

Zugschlus opened this issue Apr 16, 2022 · 0 comments
Labels
type-bug

Comments

@Zugschlus
Copy link

@Zugschlus Zugschlus commented Apr 16, 2022

Bug report

ipaddress.reverse_pointer does not seem to validate its input at all. For example:

$ python3
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> ipaddress.ip_network('2001:db8:1:2:3:4:5::/64',False).reverse_pointer
'4.6./.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
>>> 

This is very obviously wrong.

In this case of prefixed input, the output should be cut to the appropriate prefix length, yielding
2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa as output. It is ok to assume /128 as the default, converting 2001:db8:1:2:3:4:5:: to 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.1.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa, but input longer than that is an error.

Prefixed address strings are for example important when generating zone names for the server side of IPv6 reverse DNS. Run-of-the-mill network client software is unlikely to use this for addresses shorter than /128, but for the server side it is an important use case.

Greetings
Marc

@Zugschlus Zugschlus added the type-bug label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug
Projects
None yet
Development

No branches or pull requests

1 participant