This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket.getnameinfo raises SystemError on bogus input
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, marienz
Priority: normal Keywords: patch

Created on 2009-09-19 05:36 by marienz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff.patch marienz, 2009-09-19 05:36 Add explicit type check to the socket module.
diff.patch marienz, 2009-09-19 06:11 Less broken patch.
Messages (3)
msg92858 - (view) Author: Marien Zwart (marienz) * Date: 2009-09-19 05:36
socket.getnameinfo passes a PyObject* to PyArg_ParseTuple without
checking if it's a tuple first. That means it raises SystemError on
invalid input where TypeError would make more sense:

>>> socket.getnameinfo('localhost', 0)
SystemError: new style getargs format but argument is not a tuple

An explicit check for TypeError seems like the best way to fix this.
Patch (against Python 3.1.1, but it looked like this applies easily to
other branches too) attached, which also removes a bit of dead code.
msg92859 - (view) Author: Marien Zwart (marienz) * Date: 2009-09-19 06:11
Attaching a less broken patch, after Taggnostr pointed out on irc that
the code I removed is not actually dead. I really don't know why I
thought it was. I did take the opportunity to make it more obvious what
that code is actually checking for.
msg92860 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-09-19 07:35
Adapted the test that expected the SystemError (?!) and committed in
r74943. Will backport to 2.6.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51193
2009-09-19 07:35:19georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg92860

resolution: fixed
2009-09-19 06:11:13marienzsetfiles: + diff.patch

messages: + msg92859
2009-09-19 05:36:08marienzcreate