summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-29 17:36:34 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-29 17:36:34 (GMT)
commit1334884ff2f5a3968e6a26157f869b4ca5de189b (patch)
tree6cd82b8fa2964ad30b617cac8d0eaf98890d82c0 /Objects
parentc875d2032bf363da5e9e50928330f5ee2aa2fda2 (diff)
downloadcpython-1334884ff2f5a3968e6a26157f869b4ca5de189b.zip
cpython-1334884ff2f5a3968e6a26157f869b4ca5de189b.tar.gz
cpython-1334884ff2f5a3968e6a26157f869b4ca5de189b.tar.bz2
Issue #13848: open() and the FileIO constructor now check for NUL characters in the file name.
Patch by Hynek Schlawack.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 20528b9..f51d4d0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1867,6 +1867,19 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
int
+_PyUnicode_HasNULChars(PyObject* s)
+{
+ static PyObject *nul = NULL;
+
+ if (nul == NULL)
+ nul = PyUnicode_FromStringAndSize("\0", 1);
+ if (nul == NULL)
+ return -1;
+ return PyUnicode_Contains(s, nul);
+}
+
+
+int
PyUnicode_FSConverter(PyObject* arg, void* addr)
{
PyObject *output = NULL;