[SCM] Samba Shared Repository - branch master updated - tevent-0-9-8-295-g667b825
Jelmer Vernooij
jelmer at samba.org
Mon Sep 14 09:07:47 MDT 2009
The branch, master has been updated
via 667b825d183f6b438b2329aef32686c20e55b7d3 (commit)
from d106e728fb0c59900c289055c97f424e4f5d3c75 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 667b825d183f6b438b2329aef32686c20e55b7d3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 14 17:03:30 2009 +0200
pyldb: Don't segfault when invalid type is specified to Dn.get().
(#6722)
-----------------------------------------------------------------------
Summary of changes:
source4/lib/ldb/pyldb.c | 12 ++++++++++--
source4/lib/ldb/tests/python/api.py | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 3f7fa2f..b4f03dc 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1758,8 +1758,13 @@ static PyObject *py_ldb_msg_keys(PyLdbMessageObject *self)
static PyObject *py_ldb_msg_getitem_helper(PyLdbMessageObject *self, PyObject *py_name)
{
struct ldb_message_element *el;
- char *name = PyString_AsString(py_name);
+ char *name;
struct ldb_message *msg = PyLdbMessage_AsMessage(self);
+ if (!PyString_Check(py_name)) {
+ PyErr_SetNone(PyExc_TypeError);
+ return NULL;
+ }
+ name = PyString_AsString(py_name);
if (!strcmp(name, "dn"))
return PyLdbDn_FromDn(msg->dn);
el = ldb_msg_find_element(msg, name);
@@ -1786,8 +1791,11 @@ static PyObject *py_ldb_msg_get(PyLdbMessageObject *self, PyObject *args)
return NULL;
ret = py_ldb_msg_getitem_helper(self, name);
- if (ret == NULL)
+ if (ret == NULL) {
+ if (PyErr_Occurred())
+ return NULL;
Py_RETURN_NONE;
+ }
return ret;
}
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 88983ac..133bd18 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -480,6 +480,10 @@ class LdbMsgTests(unittest.TestCase):
self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
self.assertEquals("@BASEINFO", self.msg.get("dn").__str__())
+ def test_get_invalid(self):
+ self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
+ self.assertRaises(TypeError, self.msg.get, 42)
+
def test_get_other(self):
self.msg["foo"] = ["bar"]
self.assertEquals("bar", self.msg.get("foo")[0])
--
Samba Shared Repository
More information about the samba-cvs
mailing list