Antoine Pitrou <pit...@free.fr> 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=33206, st_ino=2251799813779714, st_dev=0, st_nlink=1, 
st_uid=0, st_gid=0, st_size=15132, st_atime=8589934592, st_mtime=8589934592, 
st_ctime=1301169903)

I think PyUnicode_AsUnicode should grow a NUL char check in Python 3.3, since 
it doesn't return the size anyway. I don't think we can do that in previous 
versions, though, so we need an alternate strategy. Scanning the unicode string 
for NUL characters is enough. That should be easy by using 
PyUnicode_AsUnicodeAndSize.

As for the patch:
- the test should be in test_io; you may also add a separate in test_fileio
- conv_name is never decref'ed, and so there will be a memory leak

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13848>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to