mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
python_api.c: enlarge c_arguments
array to avoid OOB write
Code below explicitly refers past `args_len`th element: c_arguments[args_len][0] = NULL; c_arguments[args_len][1] = NULL; Let's always allocate space for `NULL`. Noticed by Steffen Jaeckel.
This commit is contained in:
parent
a77a57a6a4
commit
f0a39a4b66
@ -158,7 +158,7 @@ python_api_register_command(PyObject* self, PyObject* args)
|
|||||||
c_synopsis[len] = NULL;
|
c_synopsis[len] = NULL;
|
||||||
|
|
||||||
Py_ssize_t args_len = PyList_Size(arguments);
|
Py_ssize_t args_len = PyList_Size(arguments);
|
||||||
char* c_arguments[args_len == 0 ? 0 : args_len + 1][2];
|
char* c_arguments[args_len + 1][2];
|
||||||
for (i = 0; i < args_len; i++) {
|
for (i = 0; i < args_len; i++) {
|
||||||
PyObject* item = PyList_GetItem(arguments, i);
|
PyObject* item = PyList_GetItem(arguments, i);
|
||||||
Py_ssize_t len2 = PyList_Size(item);
|
Py_ssize_t len2 = PyList_Size(item);
|
||||||
|
Loading…
Reference in New Issue
Block a user