summaryrefslogtreecommitdiff
path: root/lib/ldb-samba
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-04-20 16:23:42 +1200
committerDouglas Bagnall <dbagnall@samba.org>2019-07-10 04:32:13 +0000
commite075f52a7508979b744fde463d6184405d7a3772 (patch)
tree119873180d2cc597f83804e242dbad509b333a6a /lib/ldb-samba
parentf5e0339a0de71dc7d07f3ba95e6573076efe9efd (diff)
downloadsamba-e075f52a7508979b744fde463d6184405d7a3772.tar.gz
pyldb: fork pyldb_Ldb_AsLdbContext macro to reflect unsafeness
In the Python/C API, conversion functions which check the types of their arguments have names like: double PyFloat_AsDouble(PyObject *pyfloat); while conversion macros that don't check have names like: PyFloat_AS_DOUBLE(pyfloat) The pyldb_Ldb_AsLdbContext() macro looks like one of the checking functions but it actually isn't. This has fooled us more than once. Here we fork the macro into two -- one which performs checks and keeps the camel case, and one with a shouty name that keeps the check-free behaviour. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'lib/ldb-samba')
-rw-r--r--lib/ldb-samba/pyldb.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/ldb-samba/pyldb.c b/lib/ldb-samba/pyldb.c
index b4839785c05..48adc74b16a 100644
--- a/lib/ldb-samba/pyldb.c
+++ b/lib/ldb-samba/pyldb.c
@@ -56,7 +56,7 @@ static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O", &py_lp_ctx))
return NULL;
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
lp_ctx = lpcfg_from_py_object(ldb, py_lp_ctx);
if (lp_ctx == NULL) {
@@ -84,7 +84,7 @@ static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
return NULL;
}
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
ldb_set_opaque(ldb, "credentials", creds);
@@ -104,7 +104,7 @@ static PyObject *py_ldb_set_opaque_integer(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "si", &py_opaque_name, &value))
return NULL;
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
/* see if we have a cached copy */
old_val = (int *)ldb_get_opaque(ldb, py_opaque_name);
@@ -161,7 +161,7 @@ static PyObject *py_ldb_set_utf8_casefold(PyObject *self,
{
struct ldb_context *ldb;
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
@@ -195,7 +195,7 @@ static PyObject *py_ldb_set_session_info(PyObject *self, PyObject *args)
if (!ret)
return NULL;
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
info = PyAuthSession_AsSession(py_session_info);
@@ -216,7 +216,7 @@ static PyObject *py_ldb_samba_schema_attribute_add(PyLdbObject *self,
if (!PyArg_ParseTuple(args, "sIs", &attribute, &flags, &syntax))
return NULL;
- ldb_ctx = pyldb_Ldb_AsLdbContext(self);
+ ldb_ctx = pyldb_Ldb_AsLdbContext((PyObject *)self);
s = ldb_samba_syntax_by_name(ldb_ctx, syntax);
ret = ldb_schema_attribute_add_with_syntax(ldb_ctx, attribute,
@@ -235,7 +235,7 @@ static PyObject *py_ldb_register_samba_handlers(PyObject *self,
/* XXX: Perhaps call this from PySambaLdb's init function ? */
- ldb = pyldb_Ldb_AsLdbContext(self);
+ ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
ret = ldb_register_samba_handlers(ldb);
PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_error, ret, ldb);