From d845665e0f04feb9a0ef927fce1392568a51f90f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 27 Oct 2003 08:28:37 +0000 Subject: [PATCH] * miscfunc.cc (__check_invalid_read_ptr): New function. * winsup.h: Declare. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/miscfuncs.cc | 8 ++++++++ winsup/cygwin/winsup.h | 1 + 3 files changed, 14 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 08e7efe79..6223194bb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2003-10-27 Corinna Vinschen + + * miscfunc.cc (__check_invalid_read_ptr): New function. + * winsup.h: Declare. + 2003-10-26 Corinna Vinschen * security.h (cygpsid::debug_print): Avoid compiler warnings. diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index d9e4a7adb..be7c8a30e 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -198,6 +198,14 @@ __check_null_invalid_struct_errno (void *s, unsigned sz) return err; } +int __stdcall +__check_invalid_read_ptr (const void *s, unsigned sz) +{ + if (s && !IsBadReadPtr (s, sz)) + return 0; + return EFAULT; +} + int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) { diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 745519ea1..305b621db 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -250,6 +250,7 @@ int __stdcall check_null_empty_str_errno (const char *name) __attribute__ ((regp int __stdcall check_null_str_errno (const char *name) __attribute__ ((regparm(1))); int __stdcall __check_null_invalid_struct (void *s, unsigned sz) __attribute__ ((regparm(2))); 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))); #define check_null_invalid_struct(s) \