ntdll: NtWriteFile should fail for overlapped IO on files if offset is NULL.
This commit is contained in:
parent
6666614a19
commit
d37fac0519
|
@ -950,26 +950,35 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == FD_TYPE_FILE && offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */ )
|
if (type == FD_TYPE_FILE)
|
||||||
{
|
{
|
||||||
/* async I/O doesn't make sense on regular files */
|
if (!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT)) && !offset)
|
||||||
while ((result = pwrite( unix_handle, buffer, length, offset->QuadPart )) == -1)
|
|
||||||
{
|
{
|
||||||
if (errno != EINTR)
|
status = STATUS_INVALID_PARAMETER;
|
||||||
{
|
goto done;
|
||||||
if (errno == EFAULT) status = STATUS_INVALID_USER_BUFFER;
|
|
||||||
else status = FILE_GetNtStatus();
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
|
if (offset && offset->QuadPart != (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */)
|
||||||
/* update file pointer position */
|
{
|
||||||
lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
|
/* async I/O doesn't make sense on regular files */
|
||||||
|
while ((result = pwrite( unix_handle, buffer, length, offset->QuadPart )) == -1)
|
||||||
|
{
|
||||||
|
if (errno != EINTR)
|
||||||
|
{
|
||||||
|
if (errno == EFAULT) status = STATUS_INVALID_USER_BUFFER;
|
||||||
|
else status = FILE_GetNtStatus();
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
total = result;
|
if (options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT))
|
||||||
status = STATUS_SUCCESS;
|
/* update file pointer position */
|
||||||
goto done;
|
lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
|
||||||
|
|
||||||
|
total = result;
|
||||||
|
status = STATUS_SUCCESS;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
|
|
@ -2109,21 +2109,15 @@ todo_wine
|
||||||
bytes = 0xdeadbeef;
|
bytes = 0xdeadbeef;
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL);
|
ret = WriteFile(hfile, contents, sizeof(contents), &bytes, NULL);
|
||||||
todo_wine
|
|
||||||
ok(!ret, "WriteFile should fail\n");
|
ok(!ret, "WriteFile should fail\n");
|
||||||
todo_wine
|
|
||||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
|
||||||
todo_wine
|
|
||||||
ok(bytes == 0, "bytes %u\n", bytes);
|
ok(bytes == 0, "bytes %u\n", bytes);
|
||||||
|
|
||||||
iob.Status = -1;
|
iob.Status = -1;
|
||||||
iob.Information = -1;
|
iob.Information = -1;
|
||||||
status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), NULL, NULL);
|
status = pNtWriteFile(hfile, 0, NULL, NULL, &iob, contents, sizeof(contents), NULL, NULL);
|
||||||
todo_wine
|
|
||||||
ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
|
ok(status == STATUS_INVALID_PARAMETER, "expected STATUS_INVALID_PARAMETER, got %#x\n", status);
|
||||||
todo_wine
|
|
||||||
ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
|
ok(iob.Status == -1, "expected -1, got %#x\n", iob.Status);
|
||||||
todo_wine
|
|
||||||
ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
|
ok(iob.Information == -1, "expected -1, got %ld\n", iob.Information);
|
||||||
|
|
||||||
iob.Status = -1;
|
iob.Status = -1;
|
||||||
|
|
Loading…
Reference in New Issue