diff options
author | DJ Delorie <dj@redhat.com> | 2000-05-08 20:13:54 +0400 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-05-08 20:13:54 +0400 |
commit | c469b6a2b0c53361ca88fe3d0a840523bd149e44 (patch) | |
tree | cf1064f69d122fadf9e0d64eb9b7db446bc6e0fb | |
parent | 31ca470d432f065984509cc07226284a4f2f24b5 (diff) |
* fhandler.cc (lock): use signed math to allow checking ranges
properly.
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 17 |
2 files changed, 14 insertions, 8 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e2e6116a6..42482a6dc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2000-05-08 DJ Delorie <dj@cygnus.com> + + * fhandler.cc (lock): use signed math to allow checking ranges + properly. + Sat May 6 23:22:25 2000 Christopher Faylor <cgf@cygnus.com> * dcrt0.cc (insert_file): Eliminate unused parameter. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 45064c04d..a5a6e91a9 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1243,8 +1243,8 @@ fhandler_disk_file::close () int fhandler_disk_file::lock (int cmd, struct flock *fl) { - DWORD win32_start; - DWORD win32_len; + int win32_start; + int win32_len; DWORD win32_upper; DWORD startpos; @@ -1304,7 +1304,8 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) if (win32_start < 0) { - win32_len -= win32_start; + /* watch the signs! */ + win32_len -= -win32_start; if (win32_len <= 0) { /* Failure ! */ @@ -1337,17 +1338,17 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) ov.Internal = 0; ov.InternalHigh = 0; - ov.Offset = win32_start; + ov.Offset = (DWORD)win32_start; ov.OffsetHigh = 0; ov.hEvent = (HANDLE) 0; if (fl->l_type == F_UNLCK) { - res = UnlockFileEx (get_handle (), 0, win32_len, win32_upper, &ov); + res = UnlockFileEx (get_handle (), 0, (DWORD)win32_len, win32_upper, &ov); } else { - res = LockFileEx (get_handle (), lock_flags, 0, win32_len, + res = LockFileEx (get_handle (), lock_flags, 0, (DWORD)win32_len, win32_upper, &ov); /* Deal with the fail immediately case. */ /* @@ -1366,10 +1367,10 @@ fhandler_disk_file::lock (int cmd, struct flock *fl) { /* Windows 95 -- use primitive lock call */ if (fl->l_type == F_UNLCK) - res = UnlockFile (get_handle (), win32_start, 0, win32_len, + res = UnlockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper); else - res = LockFile (get_handle (), win32_start, 0, win32_len, win32_upper); + res = LockFile (get_handle (), (DWORD)win32_start, 0, (DWORD)win32_len, win32_upper); } if (res == 0) |