From c2ae3f11241aaf891599d3bd48d1a1e62e9fdb08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Fri, 9 Jan 2004 20:22:38 +0000 Subject: [PATCH] Never try to stuff more into the Ioctl OutputBuffer than will fit svn path=/trunk/; revision=7533 --- reactos/ntoskrnl/io/cleanup.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/cleanup.c b/reactos/ntoskrnl/io/cleanup.c index c3fc57a89bb..eb91d2a44cc 100644 --- a/reactos/ntoskrnl/io/cleanup.c +++ b/reactos/ntoskrnl/io/cleanup.c @@ -15,6 +15,7 @@ #include #include #include +#include #define NDEBUG #include @@ -38,8 +39,19 @@ VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject, else { IoControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode; - OutputBufferLength = NT_SUCCESS(Irp->IoStatus.Status) - ? Irp->IoStatus.Information : 0; + if (NT_SUCCESS(Irp->IoStatus.Status)) + { + OutputBufferLength = Irp->IoStatus.Information; + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < OutputBufferLength) + { + Irp->IoStatus.Status = STATUS_DATA_OVERRUN; + OutputBufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength; + } + } + else + { + OutputBufferLength = 0; + } } switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))