From 657af5a27480ac7fbcaa4fa4b67bbf496da32a35 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 10 Jun 2012 20:30:27 +1000 Subject: pyldb: Ensure that the ldb argument is really an ldb before we dereference --- lib/ldb/pyldb.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index ea7b695d6d..4554886e8d 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -653,6 +653,11 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa &py_ldb, &str)) return NULL; + if (!PyLdb_Check(py_ldb)) { + PyErr_SetString(PyExc_TypeError, "Expected Ldb"); + return NULL; + } + ldb_ctx = pyldb_Ldb_AsLdbContext(py_ldb); mem_ctx = talloc_new(NULL); @@ -2482,6 +2487,11 @@ static PyObject *py_ldb_msg_from_dict(PyTypeObject *type, PyObject *args) return NULL; } + if (!PyLdb_Check(py_ldb)) { + PyErr_SetString(PyExc_TypeError, "Expected Ldb"); + return NULL; + } + /* mask only flags we are going to use */ mod_flags = LDB_FLAG_MOD_TYPE(mod_flags); if (!mod_flags) { -- cgit