CVE-2023-4154 py_security: allow idx argument to descriptor.[s|d]acl_add()
authorStefan Metzmacher <metze@samba.org>
Thu, 16 Mar 2023 09:11:05 +0000 (10:11 +0100)
committerJule Anger <janger@samba.org>
Sun, 8 Oct 2023 20:06:18 +0000 (22:06 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15424

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit 9ea06aaf9f57e3c7094553d9ac40fb73057a9b74)

source4/librpc/ndr/py_security.c

index ff3de775af6d289fe6fef18633653912172e54ea..ac92f3a47a36313a8f66adff69ca7cdf7cfb6038 100644 (file)
@@ -176,12 +176,13 @@ static PyObject *py_descriptor_sacl_add(PyObject *self, PyObject *args)
        NTSTATUS status;
        struct security_ace *ace;
        PyObject *py_ace;
+       Py_ssize_t idx = -1;
 
-       if (!PyArg_ParseTuple(args, "O", &py_ace))
+       if (!PyArg_ParseTuple(args, "O|n", &py_ace, &idx))
                return NULL;
 
        ace = pytalloc_get_ptr(py_ace);
-       status = security_descriptor_sacl_add(desc, ace);
+       status = security_descriptor_sacl_insert(desc, ace, idx);
        PyErr_NTSTATUS_IS_ERR_RAISE(status);
        Py_RETURN_NONE;
 }
@@ -192,13 +193,14 @@ static PyObject *py_descriptor_dacl_add(PyObject *self, PyObject *args)
        NTSTATUS status;
        struct security_ace *ace;
        PyObject *py_ace;
+       Py_ssize_t idx = -1;
 
-       if (!PyArg_ParseTuple(args, "O", &py_ace))
+       if (!PyArg_ParseTuple(args, "O|n", &py_ace, &idx))
                return NULL;
 
        ace = pytalloc_get_ptr(py_ace);
 
-       status = security_descriptor_dacl_add(desc, ace);
+       status = security_descriptor_dacl_insert(desc, ace, idx);
        PyErr_NTSTATUS_IS_ERR_RAISE(status);
        Py_RETURN_NONE;
 }