]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:pysmbd: fix fd leak in py_smbd_create_file()
authorStefan Metzmacher <metze@samba.org>
Tue, 9 Feb 2021 12:48:36 +0000 (13:48 +0100)
committerKarolin Seeger <kseeger@samba.org>
Tue, 16 Feb 2021 21:35:14 +0000 (21:35 +0000)
Various 'samba-tool domain backup' commands use this and will
fail if there's over ~1000 files in the sysvol folder.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13898

Signed-off-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit d8fa464a2dfb11df4e1db4ebffe8bd28ff118c75)

source3/smbd/pysmbd.c

index 39fe875a385b34db1c010306d354c75c9a0d69a5..58c96396e084cfd57a5c4b1202e4c9e5bd0f1b4b 100644 (file)
@@ -1113,9 +1113,12 @@ static PyObject *py_smbd_create_file(PyObject *self, PyObject *args, PyObject *k
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("init_files_struct failed: %s\n",
                        nt_errstr(status));
+       } else if (fsp != NULL) {
+               SMB_VFS_CLOSE(fsp);
        }
 
        TALLOC_FREE(frame);
+       PyErr_NTSTATUS_NOT_OK_RAISE(status);
        Py_RETURN_NONE;
 }