diff --git a/dll/shellext/shellbtrfs/shellbtrfs.rc b/dll/shellext/shellbtrfs/shellbtrfs.rc index 845d8bc7844..26d3d6aa67e 100644 --- a/dll/shellext/shellbtrfs/shellbtrfs.rc +++ b/dll/shellext/shellbtrfs/shellbtrfs.rc @@ -61,8 +61,8 @@ IDI_ICON1 ICON "subvol.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,7,6,0 - PRODUCTVERSION 1,7,6,0 + FILEVERSION 1,7,7,0 + PRODUCTVERSION 1,7,7,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -78,12 +78,12 @@ BEGIN BLOCK "080904b0" BEGIN VALUE "FileDescription", "WinBtrfs shell extension" - VALUE "FileVersion", "1.7.6" + VALUE "FileVersion", "1.7.7" VALUE "InternalName", "btrfs" VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-21" VALUE "OriginalFilename", "shellbtrfs.dll" VALUE "ProductName", "WinBtrfs" - VALUE "ProductVersion", "1.7.6" + VALUE "ProductVersion", "1.7.7" END END BLOCK "VarFileInfo" diff --git a/dll/shellext/shellbtrfs/volpropsheet.cpp b/dll/shellext/shellbtrfs/volpropsheet.cpp index 128ac8e42b5..a2f50fac2aa 100644 --- a/dll/shellext/shellbtrfs/volpropsheet.cpp +++ b/dll/shellext/shellbtrfs/volpropsheet.cpp @@ -1476,7 +1476,7 @@ HRESULT __stdcall BtrfsVolPropSheet::ReplacePage(UINT uPageID, LPFNADDPROPSHEETP void BtrfsChangeDriveLetter::do_change(HWND hwndDlg) { unsigned int sel = (unsigned int)SendDlgItemMessageW(hwndDlg, IDC_DRIVE_LETTER_COMBO, CB_GETCURSEL, 0, 0); - if (sel >= 0 && sel < letters.size()) { + if (sel < letters.size()) { wstring dd; if (fn.length() == 3 && fn[1] == L':' && fn[2] == L'\\') { diff --git a/dll/win32/ubtrfs/ubtrfs.rc b/dll/win32/ubtrfs/ubtrfs.rc index 27eef7a7c0b..c12381e9f56 100644 --- a/dll/win32/ubtrfs/ubtrfs.rc +++ b/dll/win32/ubtrfs/ubtrfs.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,7,6,0 - PRODUCTVERSION 1,7,6,0 + FILEVERSION 1,7,7,0 + PRODUCTVERSION 1,7,7,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,12 +68,12 @@ BEGIN BLOCK "080904b0" BEGIN VALUE "FileDescription", "Btrfs utility DLL" - VALUE "FileVersion", "1.7.6" + VALUE "FileVersion", "1.7.7" VALUE "InternalName", "ubtrfs" VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-21" VALUE "OriginalFilename", "ubtrfs.dll" VALUE "ProductName", "WinBtrfs" - VALUE "ProductVersion", "1.7.6" + VALUE "ProductVersion", "1.7.7" END END BLOCK "VarFileInfo" diff --git a/drivers/filesystems/btrfs/btrfs.inf b/drivers/filesystems/btrfs/btrfs.inf index 42a3e97068c..e0f6148cdae 100644 --- a/drivers/filesystems/btrfs/btrfs.inf +++ b/drivers/filesystems/btrfs/btrfs.inf @@ -2,7 +2,7 @@ ;;; WinBtrfs ;;; ;;; -;;; Copyright (c) 2016-20 Mark Harmstone +;;; Copyright (c) 2016-21 Mark Harmstone ;;; [Version] @@ -10,7 +10,7 @@ Signature = "$Windows NT$" Class = Volume ClassGuid = {71a27cdd-812a-11d0-bec7-08002be2092f} Provider = %Me% -DriverVer = 01/14/2021,1.7.6.0 +DriverVer = 04/12/2021,1.7.7.0 CatalogFile = btrfs.cat [DestinationDirs] diff --git a/drivers/filesystems/btrfs/btrfs.rc b/drivers/filesystems/btrfs/btrfs.rc index 198fcc4e8a9..b4358b2419d 100644 --- a/drivers/filesystems/btrfs/btrfs.rc +++ b/drivers/filesystems/btrfs/btrfs.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,7,6,0 - PRODUCTVERSION 1,7,6,0 + FILEVERSION 1,7,7,0 + PRODUCTVERSION 1,7,7,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,12 +68,12 @@ BEGIN BLOCK "080904b0" BEGIN VALUE "FileDescription", "WinBtrfs" - VALUE "FileVersion", "1.7.6" + VALUE "FileVersion", "1.7.7" VALUE "InternalName", "btrfs" VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-21" VALUE "OriginalFilename", "btrfs.sys" VALUE "ProductName", "WinBtrfs" - VALUE "ProductVersion", "1.7.6" + VALUE "ProductVersion", "1.7.7" END END BLOCK "VarFileInfo" diff --git a/drivers/filesystems/btrfs/create.c b/drivers/filesystems/btrfs/create.c index e678a096167..a5a8a2316a2 100644 --- a/drivers/filesystems/btrfs/create.c +++ b/drivers/filesystems/btrfs/create.c @@ -195,6 +195,10 @@ NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb* fcb, root** subvol, uin } else fnus = *filename; + Status = check_file_name_valid(filename, false, false); + if (!NT_SUCCESS(Status)) + return Status; + hash = calc_crc32c(0xffffffff, (uint8_t*)fnus.Buffer, fnus.Length); c = hash >> 24; @@ -1604,6 +1608,9 @@ NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_ex TRACE("could not find %.*S\n", (int)(name->Length / sizeof(WCHAR)), name->Buffer); return lastpart ? STATUS_OBJECT_NAME_NOT_FOUND : STATUS_OBJECT_PATH_NOT_FOUND; + } else if (Status == STATUS_OBJECT_NAME_INVALID) { + TRACE("invalid filename: %.*S\n", (int)(name->Length / sizeof(WCHAR)), name->Buffer); + return Status; } else if (!NT_SUCCESS(Status)) { ERR("find_file_in_dir returned %08lx\n", Status); return Status; @@ -1804,7 +1811,7 @@ NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusiv Status = open_fileref_child(Vcb, sf, &nb->us, cs, lastpart, streampart, pooltype, &sf2, Irp); if (!NT_SUCCESS(Status)) { - if (Status == STATUS_OBJECT_PATH_NOT_FOUND || Status == STATUS_OBJECT_NAME_NOT_FOUND) + if (Status == STATUS_OBJECT_PATH_NOT_FOUND || Status == STATUS_OBJECT_NAME_NOT_FOUND || Status == STATUS_OBJECT_NAME_INVALID) TRACE("open_fileref_child returned %08lx\n", Status); else ERR("open_fileref_child returned %08lx\n", Status); @@ -4668,7 +4675,7 @@ loaded: TRACE("file doesn't exist, returning STATUS_OBJECT_NAME_NOT_FOUND\n"); goto exit; } - } else if (Status == STATUS_OBJECT_PATH_NOT_FOUND) { + } else if (Status == STATUS_OBJECT_PATH_NOT_FOUND || Status == STATUS_OBJECT_NAME_INVALID) { TRACE("open_fileref returned %08lx\n", Status); goto exit; } else { diff --git a/drivers/filesystems/btrfs/dirctrl.c b/drivers/filesystems/btrfs/dirctrl.c index b13dd2a22ff..a7f7f0c0953 100644 --- a/drivers/filesystems/btrfs/dirctrl.c +++ b/drivers/filesystems/btrfs/dirctrl.c @@ -326,7 +326,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileBothDirectoryInformation\n"); - needed = sizeof(FILE_BOTH_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_BOTH_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -366,7 +366,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileDirectoryInformation\n"); - needed = sizeof(FILE_DIRECTORY_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_DIRECTORY_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -404,7 +404,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileFullDirectoryInformation\n"); - needed = sizeof(FILE_FULL_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_FULL_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -443,7 +443,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileIdBothDirectoryInformation\n"); - needed = sizeof(FILE_ID_BOTH_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_ID_BOTH_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -484,7 +484,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileIdFullDirectoryInformation\n"); - needed = sizeof(FILE_ID_FULL_DIR_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_ID_FULL_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -529,7 +529,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileIdExtdDirectoryInformation\n"); - needed = offsetof(FILE_ID_EXTD_DIR_INFORMATION, FileName[0]) + de->name.Length; + needed = offsetof(FILE_ID_EXTD_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -572,7 +572,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileIdExtdBothDirectoryInformation\n"); - needed = offsetof(FILE_ID_EXTD_BOTH_DIR_INFORMATION, FileName[0]) + de->name.Length; + needed = offsetof(FILE_ID_EXTD_BOTH_DIR_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -622,7 +622,7 @@ static NTSTATUS query_dir_item(fcb* fcb, ccb* ccb, void* buf, LONG* len, PIRP Ir TRACE("FileNamesInformation\n"); - needed = sizeof(FILE_NAMES_INFORMATION) - sizeof(WCHAR) + de->name.Length; + needed = offsetof(FILE_NAMES_INFORMATION, FileName) + de->name.Length; if (needed > *len) { TRACE("buffer overflow - %li > %lu\n", needed, *len); @@ -839,7 +839,8 @@ static NTSTATUS query_directory(PIRP Irp) { if (FsRtlDoesNameContainWildCards(IrpSp->Parameters.QueryDirectory.FileName)) { has_wildcard = true; specific_file = false; - } + } else if (!initial) + return STATUS_NO_MORE_FILES; } if (ccb->query_string.Buffer) diff --git a/drivers/filesystems/btrfs/fastio.c b/drivers/filesystems/btrfs/fastio.c index 2c768895f8d..a5f577efb93 100644 --- a/drivers/filesystems/btrfs/fastio.c +++ b/drivers/filesystems/btrfs/fastio.c @@ -354,18 +354,11 @@ static BOOLEAN __stdcall fast_io_write(PFILE_OBJECT FileObject, PLARGE_INTEGER F return false; } - if (!ExAcquireResourceExclusiveLite(fcb->Header.Resource, Wait)) { - ExReleaseResourceLite(&fcb->Vcb->tree_lock); - FsRtlExitFileSystem(); - return false; - } - ret = FsRtlCopyWrite(FileObject, FileOffset, Length, Wait, LockKey, Buffer, IoStatus, DeviceObject); if (ret) fcb->inode_item.st_size = fcb->Header.FileSize.QuadPart; - ExReleaseResourceLite(fcb->Header.Resource); ExReleaseResourceLite(&fcb->Vcb->tree_lock); FsRtlExitFileSystem(); diff --git a/drivers/filesystems/btrfs/volume.c b/drivers/filesystems/btrfs/volume.c index 3ee63ed29f6..2cf660a903c 100644 --- a/drivers/filesystems/btrfs/volume.c +++ b/drivers/filesystems/btrfs/volume.c @@ -307,6 +307,9 @@ static NTSTATUS vol_query_device_name(volume_device_extension* vde, PIRP Irp) { PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PMOUNTDEV_NAME name; + if (IrpSp->FileObject && IrpSp->FileObject->FsContext) + return STATUS_INVALID_PARAMETER; + if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUNTDEV_NAME)) { Irp->IoStatus.Information = sizeof(MOUNTDEV_NAME); return STATUS_BUFFER_TOO_SMALL;