Skip to content

Incorrect ipaddress.ip_address.reverse_pointer with improved textual representation of IPv4-mapped IPv6 addresses #123409

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

Closed
kellyjonbrazil opened this issue Aug 27, 2024 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@kellyjonbrazil
Copy link

kellyjonbrazil commented Aug 27, 2024

Bug report

Bug description:

I'm seeing strange results with python 3.13 with the ipaddress.ip_address.reverse_pointer attribute with the new improved textual representation of IPv4-mapped IPv6 addresses:

IP Address: ::FFFF:192.168.1.35

Results in a reverse_pointer of:

5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

instead of the old:

3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

Python 3.13:

>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

Python 3.12:

>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

I'm not sure which one is more valid or if a pointer record is even relevant in the context of mapped addresses. The original way seems more correct to me if nothing for the fact that there are strange extra dots in the new output.

This is related to:

Issue: #87799

PR: #29345

Originally posted by @kellyjonbrazil in #87799 (comment)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@opavlyuk

Linked PRs

@picnixz
Copy link
Member

picnixz commented Aug 28, 2024

I think there is indeed an issue with the reverse pointer of IPv6. It does not match the RFC. I'll provide a patch.

@picnixz picnixz self-assigned this Aug 28, 2024
@opavlyuk
Copy link
Contributor

@kellyjonbrazil Godd catch! Thank you for logging that, and I apologize for missing it during testing.
@picnixz thank you for taking care of this!

encukou pushed a commit that referenced this issue Sep 2, 2024
GH-123419)

Fix functionality that was broken with better textual representation for IPv4-mapped addresses (gh-87799)
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 2, 2024
…dresses (pythonGH-123419)

Fix functionality that was broken with better textual representation for IPv4-mapped addresses (pythongh-87799)
(cherry picked from commit 77a2fb4)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Yhg1s pushed a commit that referenced this issue Sep 2, 2024
…ddresses (GH-123419) (#123606)

gh-123409: fix `IPv6Address.reverse_pointer` for IPv4-mapped addresses (GH-123419)

Fix functionality that was broken with better textual representation for IPv4-mapped addresses (gh-87799)
(cherry picked from commit 77a2fb4)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@encukou
Copy link
Member

encukou commented Sep 5, 2024

Thanks @kellyjonbrazil for the report and @picnixz for the patch!

@encukou encukou closed this as completed Sep 5, 2024
@picnixz
Copy link
Member

picnixz commented Sep 5, 2024

You're welcome! (I hope that I didn't misread the RFC because it doesn't tell anything about mapped addresses; however I assumed that we first map IPv4 to IPv6 before taking its reverse pointer, which is what was being done in 3.12.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants