1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

pyldb: don't allow py_ldb_dn_copy() with the wrong pyldb

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2024-03-18 12:24:53 +13:00 committed by Andrew Bartlett
parent d38a9e93cf
commit 8ac18495ba

View File

@ -1077,6 +1077,19 @@ static PyObject *py_ldb_dn_copy(struct ldb_dn *dn, PyLdbObject *pyldb)
struct ldb_dn *new_dn = NULL;
PyLdbDnObject *py_ret;
if (ldb_dn_get_ldb_context(dn) != pyldb->ldb_ctx) {
/*
* We can't do this, because we can't (for now) change the ldb
* pointer of the underlying dn returned by ldb_dn_copy().
*
* This error means someone editing this file got confused,
* which is quite understandable.
*/
PyErr_SetString(PyExc_RuntimeError,
"py_ldb_dn_copy can't copy to a new LDB");
return NULL;
}
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
return PyErr_NoMemory();