This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH] pread() returns non-zero if read beyond EOF, because NtReadFile returns EOF status but doesn't set information to 0. Need reset io status block before NtReadFile is called, so that pread() will return 0 if read beyond EOF.
- From: "Xiaofeng Liu via cygwin-patches" <cygwin-patches at cygwin dot com>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Tue, 7 Nov 2017 17:33:12 +0000 (UTC)
- Subject: [PATCH] pread() returns non-zero if read beyond EOF, because NtReadFile returns EOF status but doesn't set information to 0. Need reset io status block before NtReadFile is called, so that pread() will return 0 if read beyond EOF.
- Authentication-results: sourceware.org; auth=none
- References: <1958376489.4046072.1510075992854.ref@mail.yahoo.com>
- Reply-to: Xiaofeng Liu <liuxf09 at yahoo dot com>
--- winsup/cygwin/fhandler_disk_file.cc | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.ccindex bc8fead..525cb32 100644--- a/winsup/cygwin/fhandler_disk_file.cc+++ b/winsup/cygwin/fhandler_disk_file.cc@@ -1525,6 +1525,7 @@ fhandler_disk_file::pread (void *buf, size_t count, off_t offset) IO_STATUS_BLOCK io; LARGE_INTEGER off = { QuadPart:offset }; + memset(&io, 0, sizeof(io)); if (!prw_handle && prw_open (false)) goto non_atomic; status = NtReadFile (prw_handle, NULL, NULL, NULL, &io, buf, count,-- 1.7.1