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.
This commit is contained in:
Christopher Faylor
2001-06-28 02:19:57 +00:00
parent c135faa8b3
commit 7a4078ee34
10 changed files with 88 additions and 54 deletions

View File

@ -376,6 +376,7 @@ path_conv::check (const char *src, unsigned opt,
bool need_directory = 0;
bool saw_symlinks = 0;
int is_relpath;
sigframe thisframe (mainthread);
#if 0
static path_conv last_path_conv;
@ -403,7 +404,7 @@ path_conv::check (const char *src, unsigned opt,
if (!(opt & PC_NULLEMPTY))
error = 0;
else if ((error = check_null_empty_path (src)))
else if ((error = check_null_empty_str (src)))
return;
/* This loop handles symlink expansion. */
@ -2990,13 +2991,8 @@ getwd (char *buf)
extern "C" int
chdir (const char *in_dir)
{
int dir_error = check_null_empty_path (in_dir);
if (dir_error)
{
syscall_printf ("NULL or invalid input to chdir");
set_errno (dir_error);
return -1;
}
if (check_null_empty_str_errno (in_dir))
return -1;
syscall_printf ("dir '%s'", in_dir);
@ -3141,7 +3137,7 @@ extern "C"
int
cygwin_conv_to_posix_path (const char *path, char *posix_path)
{
if (check_null_empty_path_errno (path))
if (check_null_empty_str_errno (path))
return -1;
mount_table->conv_to_posix_path (path, posix_path, 1);
return 0;
@ -3151,7 +3147,7 @@ extern "C"
int
cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
{
if (check_null_empty_path_errno (path))
if (check_null_empty_str_errno (path))
return -1;
mount_table->conv_to_posix_path (path, posix_path, 0);
return 0;
@ -3354,19 +3350,6 @@ cygwin_split_path (const char *path, char *dir, char *file)
file[end - last_slash - 1] = 0;
}
int __stdcall
check_null_empty_path (const char *name)
{
MEMORY_BASIC_INFORMATION m;
if (!name || !VirtualQuery (name, &m, sizeof (m)) || (m.State != MEM_COMMIT))
return EFAULT;
if (!*name)
return ENOENT;
return 0;
}
/*****************************************************************************/
/* Return the hash value for the current win32 value.