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)
committerStefan Metzmacher <metze@samba.org>
Wed, 10 Feb 2021 14:00:32 +0000 (14:00 +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>
source3/smbd/pysmbd.c

index c78aefd32f78f45a4521469f4f90049897a2c1f8..ecbdd7a29e85bb4ccd431b09ad8d935598160176 100644 (file)
@@ -1185,9 +1185,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;
 }