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

gh-74895: getaddrinfo no longer raises OverflowError #2435

Merged
merged 9 commits into from
Feb 14, 2023

Conversation

smejkar
Copy link
Contributor

@smejkar smejkar commented Jun 27, 2017

Convert a numeric port number to a string without an intermediate C long.
This prevents raising OverflowError if the port number is out of the
C long range.
@smejkar
Copy link
Contributor Author

smejkar commented Jun 27, 2017

@serhiy-storchaka to pass checks, should I (a) wait till #2436 is merged, (b) relax test_getaddrinfo_overflow, or (c) rebase this onto #2436?

Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test output:
`FAIL: test_getaddrinfo_overflow (test.test_socket.GeneralModuleTests)

Traceback (most recent call last):
File "/home/me/Documents/cpython/Lib/test/test_socket.py", line 1370, in test_getaddrinfo_overflow
socket.getaddrinfo(None, _testcapi.LONG_MAX + 1)
AssertionError: gaierror not raised
`
Please fix.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 21, 2022
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jul 28, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Aug 29, 2022
@arhadthedev arhadthedev changed the title bpo-30710: getaddrinfo raises OverflowError gh-74895: getaddrinfo raises OverflowError Feb 13, 2023
@arhadthedev arhadthedev added extension-modules C modules in the Modules dir topic-IO labels Feb 13, 2023
@arhadthedev
Copy link
Member

@giampaolo, @gpshead (as network experts)

@smejkar smejkar mannequin mentioned this pull request Feb 13, 2023
@gpshead gpshead self-assigned this Feb 13, 2023
Some systems treat it as unsigned internally so ULONG_MAX+1 is needed, not LONG_MAX+1.
@gpshead gpshead added the type-bug An unexpected behavior, bug, or error label Feb 13, 2023
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Feb 14, 2023
Also updates our canned getaddrinfo.c implementation to actually
report an error for values outside of the u_short range it casts
the value to instead of ignoring them.
@gpshead gpshead changed the title gh-74895: getaddrinfo raises OverflowError gh-74895: getaddrinfo no longer raises OverflowError Feb 14, 2023
@gpshead
Copy link
Member

gpshead commented Feb 14, 2023

@serhiy-storchaka to pass checks, should I (a) wait till #2436 is merged, (b) relax test_getaddrinfo_overflow, or (c) rebase this onto #2436?

I effectively reworked the test, we don't actually want an error behavior on specific numeric values as we had in the past, we just want to report and error if the underlying platform's getaddrinfo() call reports an error. Not all of them do, or at least not all at the same values.

for all practical purposes I doubt it matters much. it'd be nice for values outside of 16-bit unsigned to be rejected, but that only makes strict sense for IPv4 and IPv6. Other protocols are free to treat numeric service names (aka port) differently.

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

Successfully merging this pull request may close these issues.

9 participants