From: Andrew Bartlett Date: Sun, 10 Jun 2012 10:30:27 +0000 (+1000) Subject: pyldb: Ensure that the ldb argument is really an ldb before we dereference X-Git-Tag: samba-4.0.0beta2~236 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=657af5a27480ac7fbcaa4fa4b67bbf496da32a35;p=thirdparty%2Fsamba.git pyldb: Ensure that the ldb argument is really an ldb before we dereference --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index ea7b695d6d7..4554886e8da 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) {