* miscfuncs.cc (check_invalid_virtual_addr): New function.

* winsup.h (check_invalid_virtual_addr): Declare.
	* mmap.cc (munmap): Call check_invalid_virtual_addr instead of
	IsBadReadPtr.
This commit is contained in:
Corinna Vinschen 2004-02-25 10:54:31 +00:00
parent 241f503c75
commit f9e19c0931
4 changed files with 22 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2004-02-25 Brian Ford <ford@vss.fsi.com>,
Corinna Vinschen <corinna@vinschen.de>
* miscfuncs.cc (check_invalid_virtual_addr): New function.
* winsup.h (check_invalid_virtual_addr): Declare.
* mmap.cc (munmap): Call check_invalid_virtual_addr instead of
IsBadReadPtr.
2004-02-24 Christopher Faylor <cgf@redhat.com>
* gendef (stabilize_sig_stack): Correctly align this pointer for call

View File

@ -214,6 +214,18 @@ __check_invalid_read_ptr_errno (const void *s, unsigned sz)
return set_errno (EFAULT);
}
int __stdcall
check_invalid_virtual_addr (const void *s, unsigned sz)
{
MEMORY_BASIC_INFORMATION mbuf;
void *end;
for (end = (char *) s + sz; s < end; s = (char *) s + mbuf.RegionSize)
if (!VirtualQuery (s, &mbuf, sizeof mbuf))
return EINVAL;
return 0;
}
ssize_t
check_iovec_for_read (const struct iovec *iov, int iovcnt)
{

View File

@ -641,7 +641,7 @@ munmap (void *addr, size_t len)
/* Error conditions according to SUSv3 */
if (!addr || ((DWORD)addr % getpagesize ()) || !len
|| IsBadReadPtr (addr, len))
|| check_invalid_virtual_addr (addr, len))
{
set_errno (EINVAL);
syscall_printf ("-1 = munmap(): Invalid parameters");

View File

@ -276,6 +276,7 @@ int __stdcall __check_null_invalid_struct (void *s, unsigned sz) __attribute__ (
int __stdcall __check_null_invalid_struct_errno (void *s, unsigned sz) __attribute__ ((regparm(2)));
int __stdcall __check_invalid_read_ptr (const void *s, unsigned sz) __attribute__ ((regparm(2)));
int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2)));
int __stdcall check_invalid_virtual_addr (const void *s, unsigned sz) __attribute__ ((regparm(2)));
#define check_null_invalid_struct(s) \
__check_null_invalid_struct ((s), sizeof (*(s)))