mirror of
https://github.com/winfsp/winfsp.git
synced 2026-03-06 23:59:26 -06:00
sys: FspFastIoDeviceControl: add a couple of fixes
- Check that the operation succeeded prior to copying to the output buffer. - Avoid information leaks by only copying what is necessary to the output buffer (suggestion by Tay Kiat Loong).
This commit is contained in:
@@ -80,6 +80,7 @@ BOOLEAN FspFastIoDeviceControl(
|
|||||||
FSP_RETURN(IoStatus->Status = STATUS_BUFFER_TOO_SMALL);
|
FSP_RETURN(IoStatus->Status = STATUS_BUFFER_TOO_SMALL);
|
||||||
|
|
||||||
PVOID SystemBuffer = 0;
|
PVOID SystemBuffer = 0;
|
||||||
|
|
||||||
if (0 != InputBufferLength || 0 != OutputBufferLength)
|
if (0 != InputBufferLength || 0 != OutputBufferLength)
|
||||||
{
|
{
|
||||||
SystemBuffer = FspAllocNonPaged(
|
SystemBuffer = FspAllocNonPaged(
|
||||||
@@ -115,14 +116,15 @@ BOOLEAN FspFastIoDeviceControl(
|
|||||||
|
|
||||||
if (0 != SystemBuffer)
|
if (0 != SystemBuffer)
|
||||||
{
|
{
|
||||||
if (0 != OutputBuffer)
|
if (NT_SUCCESS(IoStatus->Status) && 0 != OutputBuffer)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RtlCopyMemory(OutputBuffer, SystemBuffer, OutputBufferLength);
|
RtlCopyMemory(OutputBuffer, SystemBuffer, IoStatus->Information);
|
||||||
}
|
}
|
||||||
except (EXCEPTION_EXECUTE_HANDLER)
|
except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
IoStatus->Status = GetExceptionCode();
|
IoStatus->Status = GetExceptionCode();
|
||||||
|
IoStatus->Information = 0;
|
||||||
}
|
}
|
||||||
FspFree(SystemBuffer);
|
FspFree(SystemBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user