]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pysmbd: Fix file descriptor leaks
authorVolker Lendecke <vl@samba.org>
Tue, 28 Dec 2021 17:34:20 +0000 (18:34 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 30 Dec 2021 11:03:35 +0000 (11:03 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/pysmbd.c

index e3ed6dba5d567e3d1e0e3220fca61651fe5b9d38..e9edf6c19a84da450a909310a6e5d5ab609f40af 100644 (file)
@@ -156,6 +156,13 @@ static int set_sys_acl_conn(const char *fname,
 
        ret = SMB_VFS_SYS_ACL_SET_FD(smb_fname->fsp, acltype, theacl);
 
+       status = fd_close(smb_fname->fsp);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(frame);
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
        TALLOC_FREE(frame);
        return ret;
 }
@@ -333,6 +340,12 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx,
                        nt_errstr(status));
        }
 
+       status = fd_close(smb_fname->fsp);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(frame);
+               return status;
+       }
+
        TALLOC_FREE(frame);
 
        return status;
@@ -1042,6 +1055,13 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
                return PyErr_SetFromErrno(PyExc_OSError);
        }
 
+       status = fd_close(smb_fname->fsp);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(frame);
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+
        py_acl = py_return_ndr_struct("samba.dcerpc.smb_acl", "t", acl, acl);
 
        TALLOC_FREE(frame);