[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.
This commit is contained in:
Olga Kornievskaia 2011-06-06 18:44:59 -04:00
parent 8153733a77
commit 25cf92a60b

View file

@ -3346,27 +3346,28 @@ NTSTATUS nfs41_QueryVolumeInformation (
PFILE_FS_VOLUME_INFORMATION pVolInfo = RxContext->Info.Buffer; PFILE_FS_VOLUME_INFORMATION pVolInfo = RxContext->Info.Buffer;
DECLARE_CONST_UNICODE_STRING(Label, L"PnfsVolume"); DECLARE_CONST_UNICODE_STRING(Label, L"PnfsVolume");
SizeUsed = sizeof(FILE_FS_VOLUME_INFORMATION) + Label.Length; if (RxContext->Info.LengthRemaining >= sizeof(FILE_FS_VOLUME_INFORMATION)) {
if (RemainingLength < SizeUsed) {
#if 0
status = STATUS_BUFFER_TOO_SMALL;
RxContext->InformationToReturn = SizeUsed;
#else
/* Have to have status success for Notepad to be happy */
status = STATUS_SUCCESS;
#endif
goto out;
}
RtlZeroMemory(pVolInfo, sizeof(FILE_FS_VOLUME_INFORMATION)); RtlZeroMemory(pVolInfo, sizeof(FILE_FS_VOLUME_INFORMATION));
pVolInfo->VolumeCreationTime.QuadPart = 0; pVolInfo->VolumeCreationTime.QuadPart = 0;
pVolInfo->VolumeSerialNumber = 0xBABAFACE; pVolInfo->VolumeSerialNumber = 0xBABAFACE;
pVolInfo->SupportsObjects = FALSE; pVolInfo->SupportsObjects = FALSE;
RxContext->Info.LengthRemaining -= sizeof(FILE_FS_VOLUME_INFORMATION);
} else {
status = STATUS_BUFFER_TOO_SMALL;
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; pVolInfo->VolumeLabelLength = Label.Length;
RtlCopyMemory(&pVolInfo->VolumeLabel[0], (PVOID)Label.Buffer, Label.Length); RtlCopyMemory(&pVolInfo->VolumeLabel[0], (PVOID)Label.Buffer, Label.Length);
RxContext->Info.LengthRemaining -= SizeUsed; RxContext->Info.LengthRemaining -= Label.Length;
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
goto out; goto out;
} }
}
case FileFsDeviceInformation: case FileFsDeviceInformation:
{ {
@ -3380,7 +3381,7 @@ NTSTATUS nfs41_QueryVolumeInformation (
} }
RtlZeroMemory(pDevInfo, SizeUsed); RtlZeroMemory(pDevInfo, SizeUsed);
pDevInfo->DeviceType = RxContext->pFcb->pNetRoot->DeviceType; 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; RxContext->Info.LengthRemaining -= SizeUsed;
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
goto out; goto out;