smbd: Make "lease" const in create_file_unixpath()
authorVolker Lendecke <vl@samba.org>
Wed, 7 Aug 2019 19:37:31 +0000 (21:37 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 22:48:46 +0000 (22:48 +0000)
This is the one place where *lease actually got modified. We can
easily make a copy, "struct smb2_lease" is not too large, and this
case is pretty rare anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/open.c

index 1bb82d933d953d60ae96c09e6d79ccec6dbb1806..a2336d7819bad6807508e799e2bc6441b2f8be19 100644 (file)
@@ -4961,7 +4961,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                     uint32_t create_options,
                                     uint32_t file_attributes,
                                     uint32_t oplock_request,
-                                    struct smb2_lease *lease,
+                                    const struct smb2_lease *lease,
                                     uint64_t allocation_size,
                                     uint32_t private_flags,
                                     struct security_descriptor *sd,
@@ -4970,6 +4970,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                     files_struct **result,
                                     int *pinfo)
 {
+       struct smb2_lease none_lease;
        int info = FILE_WAS_OPENED;
        files_struct *base_fsp = NULL;
        files_struct *fsp = NULL;
@@ -5023,9 +5024,11 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                &epoch);
                if (NT_STATUS_EQUAL(status, NT_STATUS_OPLOCK_NOT_GRANTED)) {
                        /* Dynamic share file. No leases and update epoch... */
-                       lease->lease_state = SMB2_LEASE_NONE;
-                       lease->lease_epoch = epoch;
-                       lease->lease_version = version;
+                       none_lease = *lease;
+                       none_lease.lease_state = SMB2_LEASE_NONE;
+                       none_lease.lease_epoch = epoch;
+                       none_lease.lease_version = version;
+                       lease = &none_lease;
                } else if (!NT_STATUS_IS_OK(status)) {
                        goto fail;
                }