diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-06-28 05:30:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 05:30:06 (GMT) |
commit | f7eae0adfcd4c50034281b2c69f461b43b68db84 (patch) | |
tree | 02d6a582fd81f615e71c55365f1b37a774fc0a4e /Modules/_io/fileio.c | |
parent | 592eda123329bb5ce2bffcbe3701be6b909f1b2a (diff) | |
download | cpython-f7eae0adfcd4c50034281b2c69f461b43b68db84.zip cpython-f7eae0adfcd4c50034281b2c69f461b43b68db84.tar.gz cpython-f7eae0adfcd4c50034281b2c69f461b43b68db84.tar.bz2 |
[security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.
Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r-- | Modules/_io/fileio.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index a09c39f7..cc7061f 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -271,11 +271,10 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode, if (fd < 0) { #ifdef MS_WINDOWS - Py_ssize_t length; if (!PyUnicode_FSDecoder(nameobj, &stringobj)) { return -1; } - widename = PyUnicode_AsUnicodeAndSize(stringobj, &length); + widename = PyUnicode_AsUnicode(stringobj); if (widename == NULL) return -1; #else |