Dmitry Timoshkov : ntdll: NtReadFile should not fail for 0-length reads at EOF.
Alexandre Julliard
julliard at winehq.org
Thu Oct 31 16:12:40 CDT 2013
Module: wine
Branch: master
Commit: a5e80b2d600dbca37e3314c6ac677d6e883df2c7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a5e80b2d600dbca37e3314c6ac677d6e883df2c7
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Oct 30 14:24:25 2013 +0900
ntdll: NtReadFile should not fail for 0-length reads at EOF.
---
dlls/ntdll/file.c | 4 ++--
dlls/ntdll/tests/file.c | 16 ----------------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 8c8f4cf..9b05978 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -636,7 +636,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
lseek( unix_handle, offset->QuadPart + result, SEEK_SET );
total = result;
- status = total ? STATUS_SUCCESS : STATUS_END_OF_FILE;
+ status = (total || !length) ? STATUS_SUCCESS : STATUS_END_OF_FILE;
goto done;
}
}
@@ -665,7 +665,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
{
case FD_TYPE_FILE:
case FD_TYPE_CHAR:
- status = STATUS_END_OF_FILE;
+ status = length ? STATUS_END_OF_FILE : STATUS_SUCCESS;
goto done;
case FD_TYPE_SERIAL:
break;
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index d9e85fd..f857777 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -2168,12 +2168,9 @@ todo_wine
bytes = -1;
SetLastError(0xdeadbeef);
ret = ReadFile(hfile, buf, 0, &bytes, &ovl);
-todo_wine
ok(ret, "ReadFile error %d\n", GetLastError());
-todo_wine
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
ok(bytes == 0, "bytes %u\n", bytes);
-todo_wine
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
@@ -2189,11 +2186,8 @@ todo_wine
U(iob).Status = -1;
iob.Information = -1;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, NULL, NULL);
-todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
-todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
@@ -2210,11 +2204,8 @@ todo_wine
iob.Information = -1;
offset.QuadPart = sizeof(contents);
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
-todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
-todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
U(iob).Status = -1;
@@ -2231,11 +2222,8 @@ todo_wine
iob.Information = -1;
offset.QuadPart = (LONGLONG)-2 /* FILE_USE_FILE_POINTER_POSITION */;
status = pNtReadFile(hfile, 0, NULL, NULL, &iob, buf, 0, &offset, NULL);
-todo_wine
ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
-todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
for (i = -20; i < 0; i++)
@@ -2351,7 +2339,6 @@ todo_wine
/* ReadFile return value depends on Windows version and testing it is not practical */
ReadFile(hfile, buf, 0, &bytes, &ovl);
ok(bytes == 0, "bytes %u\n", bytes);
-todo_wine
ok((NTSTATUS)ovl.Internal == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx\n", ovl.Internal);
ok(ovl.InternalHigh == 0, "expected 0, got %lu\n", ovl.InternalHigh);
@@ -2547,11 +2534,8 @@ todo_wine
}
else
{
-todo_wine
ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", status);
-todo_wine
ok(U(iob).Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", U(iob).Status);
-todo_wine
ok(iob.Information == 0, "expected 0, got %lu\n", iob.Information);
}
More information about the wine-cvs
mailing list