]> granicus.if.org Git - python/commitdiff
Issue #13848: open() and the FileIO constructor now check for NUL characters in the...
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 29 Jan 2012 17:43:36 +0000 (18:43 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 29 Jan 2012 17:43:36 +0000 (18:43 +0100)
Patch by Hynek Schlawack.

1  2 
Include/unicodeobject.h
Lib/test/test_fileio.py
Lib/test/test_io.py
Misc/NEWS
Modules/_io/fileio.c
Objects/unicodeobject.c

Simple merge
Simple merge
Simple merge
diff --cc Misc/NEWS
Simple merge
index a21aa7a12d090e54936bd274423610a0fc51530b,d5b03eec26aa0d676c9301401c76d60ed1ee6a5c..34ff1e02ee136f61115dd234b04512f8b26add21
@@@ -258,10 -254,15 +258,16 @@@ fileio_init(PyObject *oself, PyObject *
  
  #ifdef MS_WINDOWS
      if (PyUnicode_Check(nameobj)) {
 -        widename = PyUnicode_AS_UNICODE(nameobj);
 -    }
 -    if (widename == NULL)
+         int rv = _PyUnicode_HasNULChars(nameobj);
+         if (rv) {
+             if (rv != -1)
+                 PyErr_SetString(PyExc_TypeError, "embedded NUL character");
+             return -1;
+         }
 +        widename = PyUnicode_AsUnicode(nameobj);
 +        if (widename == NULL)
 +            return -1;
 +    } else
  #endif
      if (fd < 0)
      {
Simple merge