]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: when going to truncate the file, explicitly set the filesize to 0
authorRalph Boehme <slow@samba.org>
Thu, 7 Aug 2025 17:15:43 +0000 (19:15 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 15 Aug 2025 15:46:35 +0000 (15:46 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
selftest/knownfail.d/samba3.smb2.lease [deleted file]
source3/smbd/open.c

diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease
deleted file mode 100644 (file)
index eb3d440..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.lease.lock3\(fileserver\)
index ac17a10b1b757a4c63dbd9625bf8c0f8323ab8fe..01c06f69c9d3831749661b7ab0de7d5b7e0bb91e 100644 (file)
@@ -4063,6 +4063,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        } else {
                if (flags & O_TRUNC) {
                        info = FILE_WAS_OVERWRITTEN;
+                       /*
+                        * We did not truncate the file yet, we're doing that
+                        * explicitly with SMB_VFS_FTRUNCATE() below under the
+                        * sharemode glock. For correct handling of RH leases in
+                        * the presence of byterange locks, the leases code
+                        * needs the "correct" filesize which should be 0 at
+                        * this place if we did the O_TRUNC at open() time.
+                        */
+                       fsp->fsp_name->st.st_ex_size = 0;
                } else {
                        info = FILE_WAS_OPENED;
                }