From: Ralph Boehme Date: Thu, 7 Aug 2025 17:15:43 +0000 (+0200) Subject: smbd: when going to truncate the file, explicitly set the filesize to 0 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=215b2c741a93023d13e8a9f82739ac3e91b64a66;p=thirdparty%2Fsamba.git smbd: when going to truncate the file, explicitly set the filesize to 0 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894 Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke --- diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease deleted file mode 100644 index eb3d4409c0a..00000000000 --- a/selftest/knownfail.d/samba3.smb2.lease +++ /dev/null @@ -1 +0,0 @@ -^samba3.smb2.lease.lock3\(fileserver\) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index ac17a10b1b7..01c06f69c9d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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; }