From 7a4078ee340b7f15c839257d6fa895d92abe0224 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 28 Jun 2001 02:19:57 +0000 Subject: Change check_null_empty_path* to check_null_empty_str* throughout. * path.cc (path_conv::check): Add signal protection here since retrieving info about remote shares can take some time. * path.h (check_null_empty_str_errno): Convert to a function prototype. * path.cc (check_null_empty_str): Move to miscfuncs.cc. * miscfuncs.cc (check_null_empty_str_errno): New function. (__check_null_invalid_struct): Ditto. (__check_null_invalid_struct_errno): Ditto. (check_null_empty_str): Change from VirtualQuery to IsBadWritePtr. * thread.cc (check_valid_pointer): Ditto. * resource.cc (getrlimit): Use check_null_invalid_struct macro for checking validity of pointer. (setrlimit): Ditto. --- winsup/cygwin/miscfuncs.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'winsup/cygwin/miscfuncs.cc') diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index d66c22549..49e7cebd9 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -9,6 +9,8 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ #include "winsup.h" +#include "cygerrno.h" +#include /********************** String Helper Functions ************************/ @@ -112,3 +114,42 @@ strcasestr (const char *searchee, const char *lookfor) return NULL; } + +int __stdcall +check_null_empty_str (const char *name) +{ + if (!name || IsBadStringPtr (name, MAX_PATH)) + return EFAULT; + + if (!*name) + return ENOENT; + + return 0; +} + +int __stdcall +check_null_empty_str_errno (const char *name) +{ + int __err; + if ((__err = check_null_empty_str (name))) + set_errno (__err); + return __err; +} + +int __stdcall +__check_null_invalid_struct (const void *s, unsigned sz) +{ + if (!s || IsBadWritePtr ((void *) s, sz)) + return EFAULT; + + return 0; +} + +int __stdcall +__check_null_invalid_struct_errno (const void *s, unsigned sz) +{ + int __err; + if ((__err = __check_null_invalid_struct (s, sz))) + set_errno (__err); + return __err; +} -- cgit v1.2.3