summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-06-27 18:08:58 (GMT)
committerGitHub <noreply@github.com>2017-06-27 18:08:58 (GMT)
commit0edffa3073b551ffeca34952529e7b292f1bd350 (patch)
treedcbf750061bcbe9da3ae9401292185b44490bb4b /Modules/_io
parent35d2ca2b94a6ff29e763ddb7727166f0592edfa2 (diff)
downloadcpython-0edffa3073b551ffeca34952529e7b292f1bd350.zip
cpython-0edffa3073b551ffeca34952529e7b292f1bd350.tar.gz
cpython-0edffa3073b551ffeca34952529e7b292f1bd350.tar.bz2
[3.6] bpo-30708: Check for null characters in PyUnicode_AsWideCharString(). (GH-2285) (#2443)
Raise a ValueError if the second argument is NULL and the wchar_t\* string contains null characters.. (cherry picked from commit e613e6add5f07ff6aad5802924596b631b707d2a)
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/winconsoleio.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 94dfe3e..346c386 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -79,7 +79,7 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
PyErr_Clear();
return '\0';
}
- decoded_wstr = PyUnicode_AsWideCharString(decoded, NULL);
+ decoded_wstr = _PyUnicode_AsWideCharString(decoded);
Py_CLEAR(decoded);
if (!decoded_wstr) {
PyErr_Clear();
@@ -311,8 +311,7 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
if (!d)
return -1;
- Py_ssize_t length;
- name = PyUnicode_AsWideCharString(decodedname, &length);
+ name = _PyUnicode_AsWideCharString(decodedname);
console_type = _PyIO_get_console_type(decodedname);
Py_CLEAR(decodedname);
if (name == NULL)
@@ -322,12 +321,6 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
"Cannot open non-console file");
return -1;
}
-
- if (wcslen(name) != length) {
- PyMem_Free(name);
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- return -1;
- }
}
s = mode;