From 290cd2f0763521ddaf3593497fa404d90ae8575e Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 30 Aug 2017 17:36:43 -0700 Subject: [PATCH] s3: vfs: Pass a valid fsp to SMB_VFS_GET_COMPRESSION We need to pass a valid fsp to SMB_VFS_GET_COMPRESSION(), or we will crash. --- source3/smbd/dosmode.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 3181f2e78a9..6e0ab1bbda1 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -579,14 +579,27 @@ static NTSTATUS dos_mode_check_compressed(connection_struct *conn, { NTSTATUS status; uint16_t compression_fmt; + bool need_close = false; + files_struct *fsp = NULL; TALLOC_CTX *tmp_ctx = talloc_new(NULL); if (tmp_ctx == NULL) { status = NT_STATUS_NO_MEMORY; goto err_out; } - status = SMB_VFS_GET_COMPRESSION(conn, tmp_ctx, NULL, smb_fname, + status = get_file_handle_for_metadata(conn, + smb_fname, + &fsp, + &need_close); + if (!NT_STATUS_IS_OK(status)) { + goto err_ctx_free; + } + + status = SMB_VFS_GET_COMPRESSION(conn, tmp_ctx, fsp, smb_fname, &compression_fmt); + if (need_close) { + close_file(NULL, fsp, NORMAL_CLOSE); + } if (!NT_STATUS_IS_OK(status)) { goto err_ctx_free; } -- 2.14.1