[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:
Serhiy Storchaka 2017-06-28 08:30:06 +03:00 • committed by GitHub
parent 592eda1233
commit f7eae0adfc
22 changed files with 115 additions and 23 deletions

View file

@ -594,8 +594,12 @@ summary_setproperty(msiobj* si, PyObject *args)
return NULL;
if (PyUnicode_Check(data)) {
WCHAR *value = _PyUnicode_AsUnicode(data);
if (value == NULL) {
return NULL;
}
status = MsiSummaryInfoSetPropertyW(si->h, field, VT_LPSTR,
0, NULL, PyUnicode_AsUnicode(data));
0, NULL, value);
} else if (PyLong_CheckExact(data)) {
long value = PyLong_AsLong(data);
if (value == -1 && PyErr_Occurred()) {