From 507e6fdce520999c5b29b3c98de945c4ff96c9a9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Jul 2012 20:48:34 +1000 Subject: s4-pydsdb: Improve PyErr_LDB_{DN,}_OR_RAISE to use py_check_dcerpc_type This checks the type rather than just dereferencing the pointer. Andrew Bartlett --- source4/dsdb/pydsdb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index d3486a41ec..08d87b957c 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -40,12 +40,19 @@ typedef intargfunc ssizeargfunc; /* FIXME: These should be in a header file somewhere */ #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \ -/* if (!PyLdb_Check(py_ldb)) { \ + if (!py_check_dcerpc_type(py_ldb, "ldb", "Ldb")) { \ PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \ return NULL; \ - } */\ + } \ ldb = pyldb_Ldb_AsLdbContext(py_ldb); +#define PyErr_LDB_DN_OR_RAISE(py_ldb_dn, dn) \ + if (!py_check_dcerpc_type(py_ldb_dn, "ldb", "Dn")) { \ + PyErr_SetString(py_ldb_get_exception(), "ldb Dn object required"); \ + return NULL; \ + } \ + dn = pyldb_Dn_AsDn(py_ldb_dn); + static PyObject *py_ldb_get_exception(void) { PyObject *mod = PyImport_ImportModule("ldb"); -- cgit