summaryrefslogtreecommitdiff
path: root/Include/unicodeobject.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-06-28 08:30:06 +0300
committerGitHub <noreply@github.com>2017-06-28 08:30:06 +0300
commitf7eae0adfcd4c50034281b2c69f461b43b68db84 (patch)
tree02d6a582fd81f615e71c55365f1b37a774fc0a4e /Include/unicodeobject.h
parent592eda123329bb5ce2bffcbe3701be6b909f1b2a (diff)
downloadcpython-git-f7eae0adfcd4c50034281b2c69f461b43b68db84.tar.gz
[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 'Include/unicodeobject.h')
-rw-r--r--Include/unicodeobject.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 0d10c71ed2..bb91568cb4 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -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 */