From 89f5654f63ba7ab292d77bf37ae6986770eb1da0 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 Mar 2024 16:42:38 +0100 Subject: [PATCH 1/2] libgpo: Fix trailing spaces in pygpo.c Reviewed-by: David Mulder (cherry picked from commit 6fb86a0fa62d93c1c84c2000f01c381a9e8217e1) --- libgpo/pygpo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index adbd5b4688d..463d199599a 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -371,7 +371,7 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds) workgroup, ldap_server, ADS_SASL_PLAIN); - + return 0; } -- 2.44.0 From 43f8ef3578ba5266f31440c105acb925eb0c928a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 Mar 2024 13:17:19 +0100 Subject: [PATCH 2/2] libgpo: Do not segfault if we don't have a valid security descriptor Program received signal SIGSEGV, Segmentation fault. ndr_push_security_descriptor (ndr=ndr@entry=0x555555bf41b0, ndr_flags=ndr_flags@entry=768, r=r@entry=0x0) at librpc/gen_ndr/ndr_security.c:713 713 NDR_CHECK(ndr_push_security_descriptor_revision(ndr, NDR_SCALARS, r->revision)); Thread 1 (Thread 0x7ffff7ece740 (LWP 21460) "python3"): #0 ndr_push_security_descriptor (ndr=ndr@entry=0x555555bf41b0, ndr_flags=ndr_flags@entry=768, r=r@entry=0x0) at librpc/gen_ndr/ndr_security.c:713 _flags_save_STRUCT = 0 _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = _status = __FUNCTION__ = "ndr_push_security_descriptor" #1 0x00007ffff617237f in ndr_push_struct_blob (blob=blob@entry=0x7fffffffdb20, mem_ctx=0x555555aa3bd0, p=0x0, fn=0x7ffff6074ad0 , fn@entry=0x7ffff60706c8 ) at ../../librpc/ndr/ndr.c:1438 _status = ndr = 0x555555bf41b0 #2 0x00007ffff607cccf in marshall_sec_desc (mem_ctx=, secdesc=, data=data@entry=0x7fffffffdb80, len=len@entry=0x7fffffffdb78) at ../../libcli/security/secdesc.c:241 blob = {data = 0x7fffffffdb40 "`\333\377\377\377\177", length = 140737352374299} ndr_err = __FUNCTION__ = "marshall_sec_desc" #3 0x00007ffff29edd94 in GPO_marshall_get_sec_desc_buf (self=, args=, kwds=) at ../../libgpo/pygpo.c:119 gpo_ptr = status = data = 0x0 len = 0 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15599 Signed-off-by: Andreas Schneider Reviewed-by: David Mulder (cherry picked from commit b13d4359f2f16e391763d1dc6a5718def973fabb) --- libgpo/pygpo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index 463d199599a..0f7116313f2 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -116,6 +116,11 @@ static PyObject *GPO_marshall_get_sec_desc_buf(PyObject *self, PyObject *args, uint8_t *data = NULL; size_t len = 0; + if (gpo_ptr->security_descriptor == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Uninitialized"); + return NULL; + } + status = marshall_sec_desc(gpo_ptr, gpo_ptr->security_descriptor, &data, &len); if (!NT_STATUS_IS_OK(status)) { -- 2.44.0