diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 4dd6bb38b3d..f53434aedf8 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -721,10 +721,7 @@ static NTSTATUS dispatch_ioctl( struct dispatch_context *context ) context->in_buff = out_buff; } else - { out_buff = context->in_buff; - out_size = context->in_size; - } } irp = IoBuildDeviceIoControlRequest( context->params.ioctl.code, device, context->in_buff, diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 0506011ce56..67f22a4b2b0 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -1777,17 +1777,14 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st static NTSTATUS test_basic_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG_PTR *info) { - ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; + ULONG length = min(stack->Parameters.DeviceIoControl.OutputBufferLength, sizeof(teststr)); char *buffer = irp->AssociatedIrp.SystemBuffer; if (!buffer) return STATUS_ACCESS_VIOLATION; - if (length < sizeof(teststr)) - return STATUS_BUFFER_TOO_SMALL; - - memcpy(buffer, teststr, sizeof(teststr)); - *info = sizeof(teststr); + memcpy(buffer, teststr, length); + *info = length; return STATUS_SUCCESS; } diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index eb58878cec4..76bcf0d0ce6 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -190,8 +190,8 @@ static void main_test(void) static void test_basic_ioctl(void) { + char inbuf[64], buf[32]; DWORD written; - char buf[32]; BOOL res; res = DeviceIoControl(device, IOCTL_WINETEST_BASIC_IOCTL, NULL, 0, buf, @@ -199,6 +199,13 @@ static void test_basic_ioctl(void) ok(res, "DeviceIoControl failed: %u\n", GetLastError()); ok(written == sizeof(teststr), "got size %d\n", written); ok(!strcmp(buf, teststr), "got '%s'\n", buf); + + memset(buf, 0, sizeof(buf)); + res = DeviceIoControl(device, IOCTL_WINETEST_BASIC_IOCTL, inbuf, + sizeof(inbuf), buf, 10, &written, NULL); + ok(res, "DeviceIoControl failed: %u\n", GetLastError()); + ok(written == 10, "got size %d\n", written); + ok(!strcmp(buf, "Wine is no"), "got '%s'\n", buf); } static void test_overlapped(void)