summaryrefslogtreecommitdiff
path: root/src/if_python.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-09-05 19:03:56 +0200
committerBram Moolenaar <Bram@vim.org>2012-09-05 19:03:56 +0200
commitcdab9051368a6437b7e40df673594147425df751 (patch)
tree79288319fdc749ff595b899a882caeeebf98c474 /src/if_python.c
parent77fceb890851e8c97c9d4bbe521dff165455d371 (diff)
downloadvim-git-cdab9051368a6437b7e40df673594147425df751.tar.gz
updated for version 7.3.657v7.3.657
Problem: Python bindings silently truncate string values containing NUL. Solution: Fail when a string contains NUL. (ZyX)
Diffstat (limited to 'src/if_python.c')
-rw-r--r--src/if_python.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/if_python.c b/src/if_python.c
index 836bf1b3f..385905e24 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -191,6 +191,7 @@ struct PyMethodDef { Py_ssize_t a; };
# define PyRun_SimpleString dll_PyRun_SimpleString
# define PyRun_String dll_PyRun_String
# define PyString_AsString dll_PyString_AsString
+# define PyString_AsStringAndSize dll_PyString_AsStringAndSize
# define PyString_FromString dll_PyString_FromString
# define PyString_FromStringAndSize dll_PyString_FromStringAndSize
# define PyString_Size dll_PyString_Size
@@ -288,6 +289,7 @@ static PyObject*(*dll_PyModule_GetDict)(PyObject *);
static int(*dll_PyRun_SimpleString)(char *);
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
static char*(*dll_PyString_AsString)(PyObject *);
+static int(*dll_PyString_AsStringAndSize)(PyObject *, char **, int *);
static PyObject*(*dll_PyString_FromString)(const char *);
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
static PyInt(*dll_PyString_Size)(PyObject *);
@@ -406,6 +408,7 @@ static struct
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
+ {"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
{"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
{"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
{"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
@@ -578,14 +581,15 @@ static PyTypeObject RangeType;
static int initialised = 0;
#define PYINITIALISED initialised
-/* Add conversion from PyInt? */
#define DICTKEY_GET(err) \
if (!PyString_Check(keyObject)) \
{ \
PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
return err; \
} \
- key = (char_u *) PyString_AsString(keyObject);
+ if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
+ return err;
+
#define DICTKEY_UNREF
#define DICTKEY_DECL