summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-09-24 12:20:20 +0100
committerKarolin Seeger <kseeger@samba.org>2018-11-05 12:44:32 +0100
commit4908da4f518fbbafe9efc514f52534b1f8d854ec (patch)
tree677191d590e948ee04600cf8d1e8632ee496f587
parent1f7757ef4eae87fbc8c35fd2bd5ba9e3e55124ce (diff)
downloadsamba-4908da4f518fbbafe9efc514f52534b1f8d854ec.tar.gz
lib/ldb: Ensure ldb.Dn can accept utf8 encoded unicode
Additionally remove the associated known fail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13616 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit cddd54e8654c94dedd57c08af1987ce03212ce20)
-rw-r--r--lib/ldb/pyldb.c30
-rw-r--r--selftest/knownfail2
2 files changed, 17 insertions, 15 deletions
diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c
index 696200291b5..a6290d9db09 100644
--- a/lib/ldb/pyldb.c
+++ b/lib/ldb/pyldb.c
@@ -857,22 +857,22 @@ static PySequenceMethods py_ldb_dn_seq = {
static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
- struct ldb_dn *ret;
- char *str;
- PyObject *py_ldb;
- struct ldb_context *ldb_ctx;
- TALLOC_CTX *mem_ctx;
- PyLdbDnObject *py_ret;
+ struct ldb_dn *ret = NULL;
+ char *str = NULL;
+ PyObject *py_ldb = NULL;
+ struct ldb_context *ldb_ctx = NULL;
+ TALLOC_CTX *mem_ctx = NULL;
+ PyLdbDnObject *py_ret = NULL;
const char * const kwnames[] = { "ldb", "dn", NULL };
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oes",
discard_const_p(char *, kwnames),
- &py_ldb, &str))
- return NULL;
+ &py_ldb, "utf8", &str))
+ goto out;
if (!PyLdb_Check(py_ldb)) {
PyErr_SetString(PyExc_TypeError, "Expected Ldb");
- return NULL;
+ goto out;
}
ldb_ctx = pyldb_Ldb_AsLdbContext(py_ldb);
@@ -880,24 +880,28 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa
mem_ctx = talloc_new(NULL);
if (mem_ctx == NULL) {
PyErr_NoMemory();
- return NULL;
+ goto out;
}
ret = ldb_dn_new(mem_ctx, ldb_ctx, str);
if (!ldb_dn_validate(ret)) {
talloc_free(mem_ctx);
PyErr_SetString(PyExc_ValueError, "unable to parse dn string");
- return NULL;
+ goto out;
}
py_ret = (PyLdbDnObject *)type->tp_alloc(type, 0);
if (py_ret == NULL) {
talloc_free(mem_ctx);
PyErr_NoMemory();
- return NULL;
+ goto out;
}
py_ret->mem_ctx = mem_ctx;
py_ret->dn = ret;
+out:
+ if (str != NULL) {
+ PyMem_Free(discard_const_p(char, str));
+ }
return (PyObject *)py_ret;
}
diff --git a/selftest/knownfail b/selftest/knownfail
index a122b27ad21..baf3d57a31a 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -349,5 +349,3 @@
# Disabling NTLM means you can't use samr to change the password
^samba.tests.ntlmdisabled.python\(ktest\).ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\)
^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
-# Ldb test api.SimpleLdb.test_utf8_ldb_Dn is expected to fail
-^ldb.python.api.SimpleLdb.test_utf8_ldb_Dn(none)