cygwin: pread() returns non-zero if read beyond EOF

NtReadFile returns EOF status but doesn't set information to 0.
Set return value explicitly on EOF.
This commit is contained in:
Xiaofeng Liu 2017-11-08 13:21:30 +01:00 committed by Corinna Vinschen
parent 2e989b2129
commit 46702f92ea
1 changed files with 5 additions and 2 deletions

View File

@ -1529,7 +1529,9 @@ fhandler_disk_file::pread (void *buf, size_t count, off_t offset)
goto non_atomic;
status = NtReadFile (prw_handle, NULL, NULL, NULL, &io, buf, count,
&off, NULL);
if (!NT_SUCCESS (status) && status != STATUS_END_OF_FILE)
if (status == STATUS_END_OF_FILE)
res = 0;
else if (!NT_SUCCESS (status))
{
if (pc.isdir ())
{
@ -1557,6 +1559,7 @@ fhandler_disk_file::pread (void *buf, size_t count, off_t offset)
__seterrno_from_nt_status (status);
return -1;
}
else
res = io.Information; /* Valid on EOF. */
}
else