Commit 61928e81 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl.exe: Pass the correct output size to IoBuildDeviceIoControlRequest().

parent 6796cd8a
......@@ -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,
......
......@@ -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;
}
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment