mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
[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.
This commit is contained in:
parent
592eda1233
commit
f7eae0adfc
22 changed files with 115 additions and 23 deletions
|
@ -756,23 +756,27 @@ PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4(
|
|||
PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4Copy(PyObject *unicode);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Return a read-only pointer to the Unicode object's internal
|
||||
Py_UNICODE buffer.
|
||||
If the wchar_t/Py_UNICODE representation is not yet available, this
|
||||
function will calculate it. */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
|
||||
PyObject *unicode /* Unicode object */
|
||||
) /* Py_DEPRECATED(3.3) */;
|
||||
#endif
|
||||
|
||||
/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
|
||||
contains null characters. */
|
||||
PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
|
||||
PyObject *unicode /* Unicode object */
|
||||
);
|
||||
|
||||
/* Return a read-only pointer to the Unicode object's internal
|
||||
Py_UNICODE buffer and save the length at size.
|
||||
If the wchar_t/Py_UNICODE representation is not yet available, this
|
||||
function will calculate it. */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
|
||||
PyObject *unicode, /* Unicode object */
|
||||
Py_ssize_t *size /* location where to save the length */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue