From 25cf92a60b06f31638e707e72943c78f94f6a9fc Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Mon, 6 Jun 2011 18:44:59 -0400 Subject: [PATCH] [driver] changing logic in volume query previously, if the supplied buffer length was smaller than the result of the volume query we returned SUCCESS and no data (ie. it was needed because Notepad passes in a buffer too small but doesn't like a buffer_too_small error.) However, it does work with buffer_overflow error and then a partial resulted returned. --- sys/nfs41_driver.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c index a922009..a8fc138 100644 --- a/sys/nfs41_driver.c +++ b/sys/nfs41_driver.c @@ -3346,26 +3346,27 @@ NTSTATUS nfs41_QueryVolumeInformation ( PFILE_FS_VOLUME_INFORMATION pVolInfo = RxContext->Info.Buffer; DECLARE_CONST_UNICODE_STRING(Label, L"PnfsVolume"); - SizeUsed = sizeof(FILE_FS_VOLUME_INFORMATION) + Label.Length; - if (RemainingLength < SizeUsed) { -#if 0 + if (RxContext->Info.LengthRemaining >= sizeof(FILE_FS_VOLUME_INFORMATION)) { + RtlZeroMemory(pVolInfo, sizeof(FILE_FS_VOLUME_INFORMATION)); + pVolInfo->VolumeCreationTime.QuadPart = 0; + pVolInfo->VolumeSerialNumber = 0xBABAFACE; + pVolInfo->SupportsObjects = FALSE; + RxContext->Info.LengthRemaining -= sizeof(FILE_FS_VOLUME_INFORMATION); + } else { status = STATUS_BUFFER_TOO_SMALL; - RxContext->InformationToReturn = SizeUsed; -#else - /* Have to have status success for Notepad to be happy */ - status = STATUS_SUCCESS; -#endif + RxContext->InformationToReturn = sizeof(FILE_FS_VOLUME_INFORMATION) + Label.Length; + goto out; + } + if (RxContext->Info.LengthRemaining < Label.Length) { + status = STATUS_BUFFER_OVERFLOW; + goto out; + } else { + pVolInfo->VolumeLabelLength = Label.Length; + RtlCopyMemory(&pVolInfo->VolumeLabel[0], (PVOID)Label.Buffer, Label.Length); + RxContext->Info.LengthRemaining -= Label.Length; + status = STATUS_SUCCESS; goto out; } - RtlZeroMemory(pVolInfo, sizeof(FILE_FS_VOLUME_INFORMATION)); - pVolInfo->VolumeCreationTime.QuadPart = 0; - pVolInfo->VolumeSerialNumber = 0xBABAFACE; - pVolInfo->SupportsObjects = FALSE; - pVolInfo->VolumeLabelLength = Label.Length; - RtlCopyMemory(&pVolInfo->VolumeLabel[0], (PVOID)Label.Buffer, Label.Length); - RxContext->Info.LengthRemaining -= SizeUsed; - status = STATUS_SUCCESS; - goto out; } case FileFsDeviceInformation: @@ -3380,7 +3381,7 @@ NTSTATUS nfs41_QueryVolumeInformation ( } RtlZeroMemory(pDevInfo, SizeUsed); pDevInfo->DeviceType = RxContext->pFcb->pNetRoot->DeviceType; - pDevInfo->Characteristics = FILE_REMOTE_DEVICE; // | FILE_READ_ONLY_DEVICE; + pDevInfo->Characteristics = FILE_REMOTE_DEVICE | FILE_DEVICE_IS_MOUNTED; RxContext->Info.LengthRemaining -= SizeUsed; status = STATUS_SUCCESS; goto out;