mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.3.657
Problem: Python bindings silently truncate string values containing NUL. Solution: Fail when a string contains NUL. (ZyX)
This commit is contained in:
@@ -191,6 +191,7 @@ struct PyMethodDef { Py_ssize_t a; };
|
|||||||
# define PyRun_SimpleString dll_PyRun_SimpleString
|
# define PyRun_SimpleString dll_PyRun_SimpleString
|
||||||
# define PyRun_String dll_PyRun_String
|
# define PyRun_String dll_PyRun_String
|
||||||
# define PyString_AsString dll_PyString_AsString
|
# define PyString_AsString dll_PyString_AsString
|
||||||
|
# define PyString_AsStringAndSize dll_PyString_AsStringAndSize
|
||||||
# define PyString_FromString dll_PyString_FromString
|
# define PyString_FromString dll_PyString_FromString
|
||||||
# define PyString_FromStringAndSize dll_PyString_FromStringAndSize
|
# define PyString_FromStringAndSize dll_PyString_FromStringAndSize
|
||||||
# define PyString_Size dll_PyString_Size
|
# define PyString_Size dll_PyString_Size
|
||||||
@@ -288,6 +289,7 @@ static PyObject*(*dll_PyModule_GetDict)(PyObject *);
|
|||||||
static int(*dll_PyRun_SimpleString)(char *);
|
static int(*dll_PyRun_SimpleString)(char *);
|
||||||
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
static PyObject *(*dll_PyRun_String)(char *, int, PyObject *, PyObject *);
|
||||||
static char*(*dll_PyString_AsString)(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_FromString)(const char *);
|
||||||
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
|
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
|
||||||
static PyInt(*dll_PyString_Size)(PyObject *);
|
static PyInt(*dll_PyString_Size)(PyObject *);
|
||||||
@@ -406,6 +408,7 @@ static struct
|
|||||||
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
{"PyRun_SimpleString", (PYTHON_PROC*)&dll_PyRun_SimpleString},
|
||||||
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
{"PyRun_String", (PYTHON_PROC*)&dll_PyRun_String},
|
||||||
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
|
{"PyString_AsString", (PYTHON_PROC*)&dll_PyString_AsString},
|
||||||
|
{"PyString_AsStringAndSize", (PYTHON_PROC*)&dll_PyString_AsStringAndSize},
|
||||||
{"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
|
{"PyString_FromString", (PYTHON_PROC*)&dll_PyString_FromString},
|
||||||
{"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
|
{"PyString_FromStringAndSize", (PYTHON_PROC*)&dll_PyString_FromStringAndSize},
|
||||||
{"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
|
{"PyString_Size", (PYTHON_PROC*)&dll_PyString_Size},
|
||||||
@@ -578,14 +581,15 @@ static PyTypeObject RangeType;
|
|||||||
static int initialised = 0;
|
static int initialised = 0;
|
||||||
#define PYINITIALISED initialised
|
#define PYINITIALISED initialised
|
||||||
|
|
||||||
/* Add conversion from PyInt? */
|
|
||||||
#define DICTKEY_GET(err) \
|
#define DICTKEY_GET(err) \
|
||||||
if (!PyString_Check(keyObject)) \
|
if (!PyString_Check(keyObject)) \
|
||||||
{ \
|
{ \
|
||||||
PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
|
PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
|
||||||
return err; \
|
return err; \
|
||||||
} \
|
} \
|
||||||
key = (char_u *) PyString_AsString(keyObject);
|
if (PyString_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
|
||||||
|
return err;
|
||||||
|
|
||||||
#define DICTKEY_UNREF
|
#define DICTKEY_UNREF
|
||||||
#define DICTKEY_DECL
|
#define DICTKEY_DECL
|
||||||
|
|
||||||
|
@@ -172,6 +172,7 @@ static void init_structs(void);
|
|||||||
# define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
|
# define PyUnicode_AsEncodedString py3_PyUnicode_AsEncodedString
|
||||||
# undef PyBytes_AsString
|
# undef PyBytes_AsString
|
||||||
# define PyBytes_AsString py3_PyBytes_AsString
|
# define PyBytes_AsString py3_PyBytes_AsString
|
||||||
|
# define PyBytes_AsStringAndSize py3_PyBytes_AsStringAndSize
|
||||||
# undef PyBytes_FromString
|
# undef PyBytes_FromString
|
||||||
# define PyBytes_FromString py3_PyBytes_FromString
|
# define PyBytes_FromString py3_PyBytes_FromString
|
||||||
# define PyFloat_FromDouble py3_PyFloat_FromDouble
|
# define PyFloat_FromDouble py3_PyFloat_FromDouble
|
||||||
@@ -273,6 +274,7 @@ static int (*py3_PyImport_AppendInittab)(const char *name, PyObject* (*initfunc)
|
|||||||
static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
|
static char* (*py3__PyUnicode_AsString)(PyObject *unicode);
|
||||||
static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
|
static PyObject* (*py3_PyUnicode_AsEncodedString)(PyObject *unicode, const char* encoding, const char* errors);
|
||||||
static char* (*py3_PyBytes_AsString)(PyObject *bytes);
|
static char* (*py3_PyBytes_AsString)(PyObject *bytes);
|
||||||
|
static int (*py3_PyBytes_AsStringAndSize)(PyObject *bytes, char **buffer, int *length);
|
||||||
static PyObject* (*py3_PyBytes_FromString)(char *str);
|
static PyObject* (*py3_PyBytes_FromString)(char *str);
|
||||||
static PyObject* (*py3_PyFloat_FromDouble)(double num);
|
static PyObject* (*py3_PyFloat_FromDouble)(double num);
|
||||||
static double (*py3_PyFloat_AsDouble)(PyObject *);
|
static double (*py3_PyFloat_AsDouble)(PyObject *);
|
||||||
@@ -379,6 +381,7 @@ static struct
|
|||||||
{"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
|
{"PyImport_AppendInittab", (PYTHON_PROC*)&py3_PyImport_AppendInittab},
|
||||||
{"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
|
{"_PyUnicode_AsString", (PYTHON_PROC*)&py3__PyUnicode_AsString},
|
||||||
{"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
|
{"PyBytes_AsString", (PYTHON_PROC*)&py3_PyBytes_AsString},
|
||||||
|
{"PyBytes_AsStringAndSize", (PYTHON_PROC*)&py3_PyBytes_AsStringAndSize},
|
||||||
{"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
|
{"PyBytes_FromString", (PYTHON_PROC*)&py3_PyBytes_FromString},
|
||||||
{"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble},
|
{"PyFloat_FromDouble", (PYTHON_PROC*)&py3_PyFloat_FromDouble},
|
||||||
{"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble},
|
{"PyFloat_AsDouble", (PYTHON_PROC*)&py3_PyFloat_AsDouble},
|
||||||
@@ -544,17 +547,20 @@ static int py3initialised = 0;
|
|||||||
|
|
||||||
#define PYINITIALISED py3initialised
|
#define PYINITIALISED py3initialised
|
||||||
|
|
||||||
/* Add conversion from PyInt? */
|
#define DICTKEY_DECL PyObject *bytes = NULL;
|
||||||
|
|
||||||
#define DICTKEY_GET(err) \
|
#define DICTKEY_GET(err) \
|
||||||
if (PyBytes_Check(keyObject)) \
|
if (PyBytes_Check(keyObject)) \
|
||||||
key = (char_u *) PyBytes_AsString(keyObject); \
|
{ \
|
||||||
|
if (PyBytes_AsStringAndSize(keyObject, (char **) &key, NULL) == -1) \
|
||||||
|
return err; \
|
||||||
|
} \
|
||||||
else if (PyUnicode_Check(keyObject)) \
|
else if (PyUnicode_Check(keyObject)) \
|
||||||
{ \
|
{ \
|
||||||
bytes = PyString_AsBytes(keyObject); \
|
bytes = PyString_AsBytes(keyObject); \
|
||||||
if (bytes == NULL) \
|
if (bytes == NULL) \
|
||||||
return err; \
|
return err; \
|
||||||
key = (char_u *) PyBytes_AsString(bytes); \
|
if (PyBytes_AsStringAndSize(bytes, (char **) &key, NULL) == -1) \
|
||||||
if (key == NULL) \
|
|
||||||
return err; \
|
return err; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
@@ -562,12 +568,11 @@ static int py3initialised = 0;
|
|||||||
PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
|
PyErr_SetString(PyExc_TypeError, _("only string keys are allowed")); \
|
||||||
return err; \
|
return err; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DICTKEY_UNREF \
|
#define DICTKEY_UNREF \
|
||||||
if (bytes != NULL) \
|
if (bytes != NULL) \
|
||||||
Py_XDECREF(bytes);
|
Py_XDECREF(bytes);
|
||||||
|
|
||||||
#define DICTKEY_DECL PyObject *bytes = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include the code shared with if_python.c
|
* Include the code shared with if_python.c
|
||||||
*/
|
*/
|
||||||
|
@@ -719,6 +719,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
657,
|
||||||
/**/
|
/**/
|
||||||
656,
|
656,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user