mirror of
https://github.com/samba-team/samba.git
synced 2025-02-14 01:57:53 +03:00
pytdb: Fix repr segfault for internal db
The problem was tdb->name is NULL for TDB_INTERNAL databases, and so it was crashing ... #0 0xb76944f3 in strlen () from /lib/i686/cmov/libc.so.6 #1 0x0809862b in PyString_FromFormatV (format=0xb72b6a26 "Tdb('%s')", vargs=0xbfc26a94 "") at ../Objects/stringobject.c:211 #2 0x08098888 in PyString_FromFormat (format=0xb72b6a26 "Tdb('%s')") at ../Objects/stringobject.c:358 #3 0xb72b65f2 in tdb_object_repr (self=0xb759e060) at ./pytdb.c:439 Cc: 597089@bugs.debian.org Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Jelmer Vernooij <jelmer@samba.org> (This used to be ctdb commit 3ff413baf04ce28eb54a80141250ae1284b2a521)
This commit is contained in:
parent
7c72d220b5
commit
95386b0283
@ -409,7 +409,9 @@ static PyGetSetDef tdb_object_getsetters[] = {
|
||||
|
||||
static PyObject *tdb_object_repr(PyTdbObject *self)
|
||||
{
|
||||
return PyString_FromFormat("Tdb('%s')", tdb_name(self->ctx));
|
||||
return PyString_FromFormat("Tdb('%s')",
|
||||
(tdb_get_flags(self->ctx) & TDB_INTERNAL) ? "<internal>"
|
||||
: tdb_name(self->ctx));
|
||||
}
|
||||
|
||||
static void tdb_object_dealloc(PyTdbObject *self)
|
||||
|
@ -25,6 +25,14 @@ class CloseTdbTests(TestCase):
|
||||
self.tdb.close()
|
||||
|
||||
|
||||
class InternalTdbTests(TestCase):
|
||||
def test_repr(self):
|
||||
self.tdb = tdb.Tdb("whatever", tdb_flags=tdb.INTERNAL)
|
||||
|
||||
# repr used to crash on internal db
|
||||
self.assertEquals(repr(self.tdb), "Tdb('<internal>')")
|
||||
|
||||
|
||||
class SimpleTdbTests(TestCase):
|
||||
def setUp(self):
|
||||
super(SimpleTdbTests, self).setUp()
|
||||
|
Loading…
x
Reference in New Issue
Block a user