pyldb: Ensure that the ldb argument is really an ldb before we dereference
authorAndrew Bartlett <abartlet@samba.org>
Sun, 10 Jun 2012 10:30:27 +0000 (20:30 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 11 Jun 2012 09:44:07 +0000 (11:44 +0200)
lib/ldb/pyldb.c

index ea7b695d6d7cfe6d409aac2f82ffd14617722f17..4554886e8da0a9eccdf6e436c5b80502e9359395 100644 (file)
@@ -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) {