* fhandler.cc (lock): use signed math to allow checking ranges

properly.
This commit is contained in:
DJ Delorie 2000-05-08 16:13:54 +00:00
parent 31ca470d43
commit c469b6a2b0
2 changed files with 14 additions and 8 deletions

View File

@ -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.

View File

@ -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)