From b5fcc55b5ec0bae2782ca29c1e868712129cfe8d Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 15 Mar 2024 17:09:53 +1300 Subject: [PATCH] pyldb: py_ldb_msg_contains() checks ldb equality We can't use PyErr_LDB_MESSAGE_OR_RAISE() here, because the return type is int, not PyObject*. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- lib/ldb/pyldb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index eeba4470277..874168b0564 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -3770,7 +3770,13 @@ static int py_ldb_msg_contains(PyLdbMessageObject *self, PyObject *py_name) { struct ldb_message_element *el = NULL; const char *name = NULL; - struct ldb_message *msg = pyldb_Message_AsMessage(self); + struct ldb_message *msg = pyldb_Message_as_message(self); + struct ldb_dn *dn = msg->dn; + + if (dn != NULL && (self->pyldb->ldb_ctx != ldb_dn_get_ldb_context(dn))) { + return -1; + } + name = PyUnicode_AsUTF8(py_name); if (name == NULL) { return -1; -- 2.34.1