1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-31 20:22:15 +03:00

ldb: Add more segfault tests DN handling

- from_dict DN use-after-free
- check for the same directly creating the ldb.Message

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett
2024-03-25 22:21:19 +13:00
parent 8ac18495ba
commit bda4e1233a

View File

@ -375,6 +375,46 @@ class SegfaultTests(samba.tests.TestCase):
del msg
dn.get_casefold()
@no_gdb_backtrace
@segfault_detector
def test_ldb_use_after_dict_init(self):
msg = ldb.Message()
samdb = self.get_samdb()
msg.dn = ldb.Dn(samdb, "CN=Test")
msg2 = ldb.Message.from_dict(samdb,
{"dn": msg.dn,
"foo": ["bar"]})
del msg
dn = msg2.dn
dn.add_child("CN=TEST")
dn.set_component(0, "CN", "Test2")
del samdb
dn.get_casefold()
@no_gdb_backtrace
@segfault_detector
def test_ldb_use_after_msg_init(self):
msg = ldb.Message()
samdb = self.get_samdb()
msg.dn = ldb.Dn(samdb, "CN=Test")
msg2 = ldb.Message(dn=msg.dn)
del msg
dn = msg2.dn
dn.add_child("CN=TEST")
dn.set_component(0, "CN", "Test2")
del samdb
dn.get_casefold()
@no_gdb_backtrace
@segfault_detector
def test_ldb_use_after_free_msg_diff(self):