Issue 6944: socket.getnameinfo raises SystemError on bogus input (original) (raw)

Issue6944

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:53 admin set github: 51193
2009-09-19 07:35:19 georg.brandl set status: open -> closednosy: + georg.brandlmessages: + resolution: fixed
2009-09-19 06:11:13 marienz set files: + diff.patchmessages: +
2009-09-19 05:36:08 marienz create