From: Joseph Sutton Date: Fri, 25 Aug 2023 02:21:24 +0000 (+1200) Subject: pyldb: Check whether Python object is a list X-Git-Tag: tevent-0.16.0~793 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93d37f8bfcac58893a514349ed47c12d27149146;p=thirdparty%2Fsamba.git pyldb: Check whether Python object is a list 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 Reviewed-by: Andrew Bartlett --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index bb491af5ada..c0f0cc0d409 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -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);