summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-11-09 00:21:57 +0200
committerKamen Mazdrashki <kamenim@samba.org>2010-11-10 09:02:00 +0000
commit7e3419f32f0a46cbd4926cbc98bf54da27749d31 (patch)
tree12687d425296adac84f454d8e7a123776f34e695 /source4/lib/ldb
parent38585a74905185e87494c7326d248495b5e01e49 (diff)
downloadsamba-7e3419f32f0a46cbd4926cbc98bf54da27749d31.tar.gz
samba-7e3419f32f0a46cbd4926cbc98bf54da27749d31.tar.bz2
samba-7e3419f32f0a46cbd4926cbc98bf54da27749d31.zip
s4-pyldb: Handle internal errors in py_ldb_contains() properly
It is an exceptional condition for ldb_search() to return more than one results during SCOPE_BASE search on DN Autobuild-User: Kamen Mazdrashki <kamenim@samba.org> Autobuild-Date: Wed Nov 10 09:02:00 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/pyldb.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index eddc56f777..1f5bd1e58d 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1428,8 +1428,9 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
unsigned int count;
int ret;
- if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn))
+ if (!PyObject_AsDn(ldb_ctx, obj, ldb_ctx, &dn)) {
return -1;
+ }
ret = ldb_search(ldb_ctx, ldb_ctx, &result, dn, LDB_SCOPE_BASE, NULL,
NULL);
@@ -1442,11 +1443,15 @@ static int py_ldb_contains(PyLdbObject *self, PyObject *obj)
talloc_free(result);
- if (count == 0) {
- return 0;
+ if (count > 1) {
+ PyErr_Format(PyExc_RuntimeError,
+ "Searching for [%s] dn gave %u results!",
+ ldb_dn_get_linearized(dn),
+ count);
+ return -1;
}
- return 1;
+ return count;
}
static PySequenceMethods py_ldb_seq = {