From: Stefan Metzmacher Date: Tue, 9 Feb 2021 12:48:36 +0000 (+0100) Subject: s3:pysmbd: fix fd leak in py_smbd_create_file() X-Git-Tag: tevent-0.11.0~1771 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8fa464a2dfb11df4e1db4ebffe8bd28ff118c75;p=thirdparty%2Fsamba.git s3:pysmbd: fix fd leak in py_smbd_create_file() 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 --- diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index c78aefd32f7..ecbdd7a29e8 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -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; }