Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2002-03-11 23:23:09 +0300
committerCorinna Vinschen <corinna@vinschen.de>2002-03-11 23:23:09 +0300
commit2817e0dc89f74ae714e863eeff94c31041e05e6e (patch)
treebad61bc51b6a020c701d864f921813093339cf8c /winsup/cygwin/mmap.cc
parentaf53a09c707a8fd0bd8eaf218d9625e0c7fe09e9 (diff)
* mmap.cc (msync): Check area given by addr and len for being a
contigeous mmap'd region.
Diffstat (limited to 'winsup/cygwin/mmap.cc')
-rw-r--r--winsup/cygwin/mmap.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index dae80e4d6..2a81d8d3c 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -674,8 +674,12 @@ msync (caddr_t addr, size_t len, int flags)
for (int li = 0; li < l->nrecs; ++li)
{
mmap_record *rec = l->recs + li;
- if (rec->get_address () == addr)
+ if (rec->access (addr))
{
+ /* Check whole area given by len. */
+ for (DWORD i = getpagesize (); i < len; ++i)
+ if (!rec->access (addr + i))
+ goto invalid_address_range;
fhandler_base *fh = rec->alloc_fh ();
int ret = fh->msync (rec->get_handle (), addr, len, flags);
rec->free_fh (fh);
@@ -688,10 +692,11 @@ msync (caddr_t addr, size_t len, int flags)
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return 0;
}
- }
- }
- }
+ }
+ }
+ }
+invalid_address_range:
/* SUSv2: Return code if indicated memory was not mapped is ENOMEM. */
set_errno (ENOMEM);
syscall_printf ("-1 = msync(): ENOMEM");