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

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-11-03 20:20:35 -06:00 committed by Alexandre Julliard
parent 6796cd8ac4
commit 61928e8160
3 changed files with 11 additions and 10 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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)