]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pyldb: Check whether Python object is a list
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 25 Aug 2023 02:21:24 +0000 (14:21 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 30 Aug 2023 02:15:28 +0000 (02:15 +0000)
If we’re going to call PyList_Size() on an object, we should be sure
that it is a list first.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c

index bb491af5ada99360244714ad705d21ec1ab0a169..c0f0cc0d409f74a5149d926db5fd520c0bcf5019 100644 (file)
@@ -454,6 +454,11 @@ static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx,
        if (obj == Py_None)
                return NULL;
 
+       if (!PyList_Check(obj)) {
+               PyErr_SetString(PyExc_ValueError, "Expected list of LDB results");
+               return NULL;
+       }
+
        res = talloc_zero(mem_ctx, struct ldb_result);
        res->count = PyList_Size(obj);
        res->msgs = talloc_array(res, struct ldb_message *, res->count);