1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

python.gpo.ADS_STRUCT: check type of loadparm argument

And add a test showning the segfault.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2018-04-13 12:29:05 +12:00 committed by Douglas Bagnall
parent a82ca08f37
commit 1b3d3304e5
2 changed files with 15 additions and 1 deletions

View File

@ -183,7 +183,14 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds)
}
if (lp_obj) {
bool ok;
bool ok = py_check_dcerpc_type(lp_obj, "samba.param",
"LoadParm");
if (!ok) {
PyErr_Format(PyExc_TypeError,
"Expected samba.param.LoadParm "
"for lp argument");
return -1;
}
lp_ctx = pytalloc_get_type(lp_obj, struct loadparm_context);
if (lp_ctx == NULL) {
return -1;

View File

@ -50,6 +50,13 @@ class GPOTests(tests.TestCase):
assert gpos[i].ds_path == ds_paths[i], \
'ds_path did not match expected %s' % gpos[i].ds_path
def test_gpo_ads_does_not_segfault(self):
try:
ads = gpo.ADS_STRUCT(self.server, 42, self.creds)
except:
pass
def test_gpt_version(self):
global gpt_data
local_path = self.lp.get("path", "sysvol")