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.

Title: msvcrt get_osfhandle crash on bad FD
Type: crash Stage: resolved
Components: IO Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, pakal, pitrou
Priority: normal Keywords: patch

Created on 2010-05-16 18:22 by pakal, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
msvcrt_crash2.patch pakal, 2010-05-17 17:16
Messages (7)
msg105872 - (view) Author: Pascal Chambon (pakal) * Date: 2010-05-16 18:22
In python trunk, _set_invalid_parameter_handler() has been dropped and replaced by custom checking functions, but in msvcrt.get_osfhandle() these checks aren't present, so providing a bad FD leads to a crash.

Here is the little fix + a test (added to test_fileio, because I can't find unit tests for the msvcrt builtin, and similar "bad fd" cases are treated there).
msg105908 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-05-17 15:09
I agree with the fix.
However the patch should test for "sys.platform == 'win32'" before importing msvcrt.
And there is an extra space on another line.
msg105917 - (view) Author: Pascal Chambon (pakal) * Date: 2010-05-17 17:16
My bad, here is a better patch...
msg105918 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-05-17 17:19
The second patch looks good to me.
msg115545 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-04 00:06
Should this be checked in?
msg115559 - (view) Author: Pascal Chambon (pakal) * Date: 2010-09-04 06:38
I guess it should, shouldn't it ?
msg115616 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-09-04 21:25
Ok, I've committed the patch in r84506 (3.x), r84507 (3.1) and r84508 (2.7). Thank you!
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 52980
2010-09-04 21:25:50pitrousetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg115616

stage: commit review -> resolved
2010-09-04 06:38:19pakalsetmessages: + msg115559
2010-09-04 00:06:10pitrousetnosy: + pitrou

messages: + msg115545
versions: + Python 3.1, Python 3.2
2010-05-17 17:19:37amaury.forgeotdarcsetresolution: accepted
messages: + msg105918
stage: patch review -> commit review
2010-05-17 17:16:21pakalsetfiles: - msvcrt_crash.patch
2010-05-17 17:16:15pakalsetfiles: + msvcrt_crash2.patch

messages: + msg105917
2010-05-17 15:09:01amaury.forgeotdarcsetnosy: + amaury.forgeotdarc

messages: + msg105908
stage: patch review
2010-05-16 18:22:11pakalcreate