[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: I've made small changes and committed the patch in 3.2 and 3.3. 2.7 would need further changes and I don't think it's worth the bother. Thanks! -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed __

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Roundup Robot
Roundup Robot added the comment: New changeset 572bb8c265c0 by Antoine Pitrou in branch '3.2': Issue #13848: open() and the FileIO constructor now check for NUL characters in the file name. http://hg.python.org/cpython/rev/572bb8c265c0 New changeset 6bb05ce1cd1f by Antoine Pitrou in branch 'de

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch works under Windows here (on branch default). -- stage: needs patch -> patch review ___ Python tracker ___ __

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Hynek Schlawack
Hynek Schlawack added the comment: With Georg's kind help I added some improvements: - I've been reluctant to waste heap for caching the nul string but he convinced me that I was being ridiculous ;) - For some reason there was a stray character inside, that should be fixed too. In related n

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-29 Thread Hynek Schlawack
Hynek Schlawack added the comment: I have fixed the refleak, added a _PyUnicode_HasNULChars and integrated it into the Win32-unicode-if-branch. Couldn't test it due to lack of win32 – the function itself is tested though. -- Added file: http://bugs.python.org/file24355/open-nul.patch

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-27 Thread Terry J. Reedy
Terry J. Reedy added the comment: See also #13849 -- nosy: +terry.reedy ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: Since the NUL-scanning will be useful for Modules/posixmodule.c as well, perhaps it should be done as a private _PyUnicode_HasNULChars() function. -- ___ Python tracker _

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-27 Thread Antoine Pitrou
Antoine Pitrou added the comment: Indeed, there seems to be no mechanism available to forbid NUL chars under Windows (for Python 3.x): >>> open("LICENSE\x00foobar") <_io.TextIOWrapper name='LICENSE\x00foobar' mode='r' encoding='cp1252'> >>> os.stat("LICENSE\x00foobar") nt.stat_result(st_mode=3

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-24 Thread Hynek Schlawack
Hynek Schlawack added the comment: So I have good news and bad news. The good is: I fixed it for non-Win platforms and the patch is truly beautiful: Lib/test/test_builtin.py | 6 ++ Modules/_io/fileio.c | 25 - 2 files changed, 10 insertions(+), 21 deletions

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-24 Thread Hynek Schlawack
Hynek Schlawack added the comment: JFTR, file()'s C equivalent is fileio_init and not io_open, I lost track of all the opens. ;) -- ___ Python tracker ___ _

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yes, fixing the conversion block is probably the right approach. Apparently posixmodule.c uses PyUnicode_FSConverter, perhaps that would work? (also make sure that the case where a bytes string is given is fixed too: >>> open(b"\x00") Traceback (most recent cal

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-24 Thread Hynek Schlawack
Hynek Schlawack added the comment: I took a deep dive into parts of CPython that were unknown to me :) and dug up the following: Methods like os.stat or even os.open convert the file name using "et" in PyArg_ParseTuple[AndKeywords]. OTOH, open() and io.open() just hand through the object as

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-23 Thread Alex Gaynor
Changes by Alex Gaynor : -- nosy: +alex ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/

[issue13848] io.open() doesn't check for embedded NUL characters

2012-01-23 Thread Antoine Pitrou
New submission from Antoine Pitrou : >>> open("\x00abc") Traceback (most recent call last): File "", line 1, in FileNotFoundError: [Errno 2] No such file or directory: '' Contrast with 2.x open(): >>> open("\x00abc") Traceback (most recent call last): File "", line 1, in TypeError: file()