This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B19: mprotect() bugs


I'm new to this list so I don't quite know the correct way to do this. I
found two bugs in the mprotect() call. The most serious is that mprotect()
will not set the protections correctly since it calls VirtualProtect() (the
Win32 call) with its UNIX-arguement "prot" instead of the Win32-translated
protection "new_prot". The second bug occurs if you try to set a range of
memory to PROT_NONE. You will always fail with EINVAL. 

Below is the diff between the original and fixed versions.

*** mmap.cc.orig	Tue Feb 10 19:14:59 1998
--- mmap.cc	Thu Apr 16 15:40:32 1998
***************
*** 273,279 ****
    syscall_printf ("mprotect (addr = %x, len = %d, prot = %x)\n",
                    addr, len, prot);
  
!   if (prot & PROT_NONE)
      new_prot = PAGE_NOACCESS;
    else 
      {
--- 273,279 ----
    syscall_printf ("mprotect (addr = %x, len = %d, prot = %x)\n",
                    addr, len, prot);
  
!   if (prot == PROT_NONE)
      new_prot = PAGE_NOACCESS;
    else 
      {
***************
*** 298,304 ****
           }
       }
  
!   if (VirtualProtect (addr, len, prot, &old_prot) == 0)
      {
        __seterrno ();
        syscall_printf ("-1 = mprotect (): lasterror = %x\n", GetLastError
());
--- 298,304 ----
           }
       }
  
!   if (VirtualProtect (addr, len, new_prot, &old_prot) == 0)
      {
        __seterrno ();
        syscall_printf ("-1 = mprotect (): lasterror = %x\n", GetLastError
());






Gilbert W. Pilz Jr.
Systems Software Consultant
gwpilz@pobox.com
www.scruz.net/~gwpilz/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]