diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-03-03 22:29:13 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-03-03 23:20:06 +0100 |
commit | 379b919e4b5e0c309bd9ef65e84350760b788b03 (patch) | |
tree | dab55edd6134786dcae81e96026f34519a57fcbe /lib | |
parent | 229935e03686ebdbd4f01cd2939e4399b68c33ec (diff) | |
download | samba-379b919e4b5e0c309bd9ef65e84350760b788b03.tar.gz samba-379b919e4b5e0c309bd9ef65e84350760b788b03.tar.xz samba-379b919e4b5e0c309bd9ef65e84350760b788b03.zip |
pyldb: Report errors converting controls list to char**
With this change, passing an unexpected type to the CRUD methods
will result in an informative TypeError.
Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/pyldb.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index a3ffde92c6..f18e06e5c6 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -1109,6 +1109,10 @@ static PyObject *py_ldb_modify(PyLdbObject *self, PyObject *args, PyObject *kwar parsed_controls = NULL; } else { const char **controls = PyList_AsStringList(mem_ctx, py_controls, "controls"); + if (controls == NULL) { + talloc_free(mem_ctx); + return NULL; + } parsed_controls = ldb_parse_control_strings(ldb_ctx, mem_ctx, controls); talloc_free(controls); } @@ -1254,6 +1258,10 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args, PyObject *kwargs) parsed_controls = NULL; } else { const char **controls = PyList_AsStringList(mem_ctx, py_controls, "controls"); + if (controls == NULL) { + talloc_free(mem_ctx); + return NULL; + } parsed_controls = ldb_parse_control_strings(ldb_ctx, mem_ctx, controls); talloc_free(controls); } @@ -1343,6 +1351,10 @@ static PyObject *py_ldb_delete(PyLdbObject *self, PyObject *args, PyObject *kwar parsed_controls = NULL; } else { const char **controls = PyList_AsStringList(mem_ctx, py_controls, "controls"); + if (controls == NULL) { + talloc_free(mem_ctx); + return NULL; + } parsed_controls = ldb_parse_control_strings(ldb_ctx, mem_ctx, controls); talloc_free(controls); } @@ -1417,6 +1429,10 @@ static PyObject *py_ldb_rename(PyLdbObject *self, PyObject *args, PyObject *kwar parsed_controls = NULL; } else { const char **controls = PyList_AsStringList(mem_ctx, py_controls, "controls"); + if (controls == NULL) { + talloc_free(mem_ctx); + return NULL; + } parsed_controls = ldb_parse_control_strings(ldb_ctx, mem_ctx, controls); talloc_free(controls); } @@ -1717,6 +1733,10 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar parsed_controls = NULL; } else { const char **controls = PyList_AsStringList(mem_ctx, py_controls, "controls"); + if (controls == NULL) { + talloc_free(mem_ctx); + return NULL; + } parsed_controls = ldb_parse_control_strings(ldb_ctx, mem_ctx, controls); talloc_free(controls); } |