-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Conversation
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.
@serhiy-storchaka to pass checks, should I (a) wait till #2436 is merged, (b) relax test_getaddrinfo_overflow, or (c) rebase this onto #2436? |
There was a problem hiding this 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.
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
@giampaolo, @gpshead (as network experts) |
Some systems treat it as unsigned internally so ULONG_MAX+1 is needed, not LONG_MAX+1.
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.
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. |
http://bugs.python.org/issue30710
Depends on http://bugs.python.org/issue30711 to pass test_getaddrinfo_overflow.