From: Douglas Bagnall Date: Thu, 4 Jul 2019 04:43:12 +0000 (+1200) Subject: pyldb: ldb.register_module() checks arguments a little bit X-Git-Tag: talloc-2.3.0~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdb9a59069c5fea131669510b59901cbe3d9e58e;p=thirdparty%2Fsamba.git pyldb: ldb.register_module() checks arguments a little bit Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 13d7c962d1e..a6069be46a9 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -4136,7 +4136,8 @@ static PyObject *py_register_module(PyObject *module, PyObject *args) int ret; struct ldb_module_ops *ops; PyObject *input; - PyObject *tmp; + PyObject *tmp = NULL; + const char *name = NULL; if (!PyArg_ParseTuple(args, "O", &input)) return NULL; @@ -4148,10 +4149,17 @@ static PyObject *py_register_module(PyObject *module, PyObject *args) } tmp = PyObject_GetAttrString(input, discard_const_p(char, "name")); - ops->name = talloc_strdup(ops, PyUnicode_AsUTF8(tmp)); - + if (tmp == NULL) { + return NULL; + } + name = PyUnicode_AsUTF8(tmp); + if (name == NULL) { + return NULL; + } Py_XDECREF(tmp); Py_INCREF(input); + + ops->name = talloc_strdup(ops, name); ops->private_data = input; ops->init_context = py_module_init; ops->search = py_module_search; diff --git a/selftest/knownfail.d/python-segfaults b/selftest/knownfail.d/python-segfaults index e5821538b6e..42f83f8b8b9 100644 --- a/selftest/knownfail.d/python-segfaults +++ b/selftest/knownfail.d/python-segfaults @@ -1,5 +1,4 @@ samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_encrypt_netr_crypt_password samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_hive_open_ldb -samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_ldb_register_module samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_net_replicate_chunk_1 samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_net_replicate_init__3