OSDN Git Service

* mmap.cc (mmap64): Avoid crash if file size is less than requested
authorcorinna <corinna>
Fri, 15 Aug 2003 12:05:08 +0000 (12:05 +0000)
committercorinna <corinna>
Fri, 15 Aug 2003 12:05:08 +0000 (12:05 +0000)
map length.

winsup/cygwin/ChangeLog
winsup/cygwin/mmap.cc

index 57f7092..ed37e0b 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * mmap.cc (mmap64): Avoid crash if file size is less than requested
+       map length.
+
 2003-08-13  Igor Pechtchanski  <pechtcha@cs.nyu.edu>
 
        * path.cc (special_name): Add checks for some specials followed by
index 7d8809e..6af4946 100644 (file)
@@ -600,7 +600,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, _off64_t off)
   }
 
   /* Insert into the list */
-  mmap_record *rec = map_list->add_record (mmap_rec, off, len);
+  mmap_record *rec = map_list->add_record (mmap_rec, off, len > gran_len ? gran_len : len);
   caddr_t ret = rec->get_address () + (off - gran_off);
   syscall_printf ("%x = mmap() succeeded", ret);
   ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");