* miscfuncs.cc (DEFAULT_STACKSIZE): Set to 1 Megs. Drop comment about

RLIMIT_STACK.

	* registry.cc (get_registry_hive_path): Expect the user hive path to
	be never longer than MAX_PATH.  Don't prepend native NT path prefix
	here.  Add comment.
	(load_registry_hive): Prepend native NT path prefix here.  Additionally
	try to load user's classes hive.
	* uinfo.cc (cygheap_user::env_userprofile): Reduce size of
	userprofile_env_buf to MAX_PATH.  Add comment.
This commit is contained in:
Corinna Vinschen 2012-02-10 20:56:22 +00:00
parent c38a2d8373
commit 793371f584
4 changed files with 51 additions and 14 deletions

View File

@ -1,3 +1,16 @@
2012-02-10 Corinna Vinschen <corinna@vinschen.de>
* miscfuncs.cc (DEFAULT_STACKSIZE): Set to 1 Megs. Drop comment about
RLIMIT_STACK.
* registry.cc (get_registry_hive_path): Expect the user hive path to
be never longer than MAX_PATH. Don't prepend native NT path prefix
here. Add comment.
(load_registry_hive): Prepend native NT path prefix here. Additionally
try to load user's classes hive.
* uinfo.cc (cygheap_user::env_userprofile): Reduce size of
userprofile_env_buf to MAX_PATH. Add comment.
2012-02-10 Christopher Faylor <me.cygwin2012@cgf.cx> 2012-02-10 Christopher Faylor <me.cygwin2012@cgf.cx>
* syscalls.cc (setsid): On second thought, in the spirit of keeping * syscalls.cc (setsid): On second thought, in the spirit of keeping

View File

@ -549,8 +549,7 @@ thread_wrapper (VOID *arg)
ExitThread (0); ExitThread (0);
} }
/* FIXME: This should be settable via setrlimit (RLIMIT_STACK). */ #define DEFAULT_STACKSIZE (1024 * 1024)
#define DEFAULT_STACKSIZE (512 * 1024)
HANDLE WINAPI HANDLE WINAPI
CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg, CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,

View File

@ -1,7 +1,7 @@
/* registry.cc: registry interface /* registry.cc: registry interface
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -214,6 +214,7 @@ reg_key::~reg_key ()
key_is_invalid = 1; key_is_invalid = 1;
} }
/* The buffer path points to should be at least MAX_PATH bytes. */
PWCHAR PWCHAR
get_registry_hive_path (PCWSTR name, PWCHAR path) get_registry_hive_path (PCWSTR name, PWCHAR path)
{ {
@ -241,8 +242,7 @@ get_registry_hive_path (PCWSTR name, PWCHAR path)
status); status);
return NULL; return NULL;
} }
wcpcpy (path, L"\\??\\"); ExpandEnvironmentStringsW (buf.Buffer, path, MAX_PATH);
ExpandEnvironmentStringsW (buf.Buffer, path + 4, NT_MAX_PATH - 4);
debug_printf ("ProfileImagePath for %W: %W", name, path); debug_printf ("ProfileImagePath for %W: %W", name, path);
return path; return path;
} }
@ -253,32 +253,56 @@ load_registry_hive (PCWSTR name)
if (!name) if (!name)
return; return;
/* Fetch the path. */ /* Fetch the path. Prepend native NT path prefix. */
tmp_pathbuf tp; tmp_pathbuf tp;
PWCHAR path = tp.w_get (); PWCHAR path = tp.w_get ();
if (!get_registry_hive_path (name, path)) if (!get_registry_hive_path (name, wcpcpy (path, L"\\??\\")))
return; return;
WCHAR key[256]; WCHAR key[256];
PWCHAR path_comp;
UNICODE_STRING ukey, upath; UNICODE_STRING ukey, upath;
OBJECT_ATTRIBUTES key_attr, path_attr; OBJECT_ATTRIBUTES key_attr, path_attr;
NTSTATUS status; NTSTATUS status;
/* Create the object attributes for key and path. */ /* Create keyname and path strings and object attributes. */
wcpcpy (wcpcpy (key, L"\\Registry\\User\\"), name); wcpcpy (wcpcpy (key, L"\\Registry\\User\\"), name);
RtlInitUnicodeString (&ukey, key); RtlInitUnicodeString (&ukey, key);
InitializeObjectAttributes (&key_attr, &ukey, OBJ_CASE_INSENSITIVE, InitializeObjectAttributes (&key_attr, &ukey, OBJ_CASE_INSENSITIVE,
NULL, NULL); NULL, NULL);
wcscat (path, L"\\NTUSER.DAT"); /* First try to load the "normal" registry hive, which is what the user
is supposed to see under HKEY_CURRENT_USER. */
path_comp = wcschr (path, L'\0');
wcpcpy (path_comp, L"\\ntuser.dat");
RtlInitUnicodeString (&upath, path); RtlInitUnicodeString (&upath, path);
InitializeObjectAttributes (&path_attr, &upath, OBJ_CASE_INSENSITIVE, InitializeObjectAttributes (&path_attr, &upath, OBJ_CASE_INSENSITIVE,
NULL, NULL); NULL, NULL);
/* Load file into key. */
status = NtLoadKey (&key_attr, &path_attr); status = NtLoadKey (&key_attr, &path_attr);
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (status))
{
debug_printf ("Loading user registry hive %S into %S failed: %p", debug_printf ("Loading user registry hive %S into %S failed: %p",
&upath, &ukey, status); &upath, &ukey, status);
else return;
}
debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %p", debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %p",
&upath, &ukey, status); &upath, &ukey, status);
/* If loading the normal hive worked, try to load the classes hive into
the sibling *_Classes subkey, which is what the user is supposed to
see under HKEY_CLASSES_ROOT, merged with the machine-wide classes. */
wcscat (key, L"_Classes");
RtlInitUnicodeString (&ukey, key);
/* Path to UsrClass.dat changed in Vista to
\\AppData\\Local\\Microsoft\\Windows\\UsrClass.dat
but old path is still available via symlinks. */
wcpcpy (path_comp, L"\\Local Settings\\Application Data\\Microsoft\\"
"Windows\\UsrClass.dat");
RtlInitUnicodeString (&upath, path);
/* Load UsrClass.dat file into key. */
status = NtLoadKey (&key_attr, &path_attr);
if (!NT_SUCCESS (status))
debug_printf ("Loading user classes hive %S into %S failed: %p",
&upath, &ukey, status);
else
debug_printf ("Loading user classes hive %S into %S SUCCEEDED: %p",
&upath, &ukey, status);
} }

View File

@ -435,12 +435,13 @@ cygheap_user::env_userprofile (const char *name, size_t namelen)
if (test_uid (puserprof, name, namelen)) if (test_uid (puserprof, name, namelen))
return puserprof; return puserprof;
WCHAR userprofile_env_buf[NT_MAX_PATH]; /* User hive path is never longer than MAX_PATH. */
WCHAR userprofile_env_buf[MAX_PATH];
WCHAR win_id[UNLEN + 1]; /* Large enough for SID */ WCHAR win_id[UNLEN + 1]; /* Large enough for SID */
cfree_and_set (puserprof, almost_null); cfree_and_set (puserprof, almost_null);
if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf)) if (get_registry_hive_path (get_windows_id (win_id), userprofile_env_buf))
sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf + 4); sys_wcstombs_alloc (&puserprof, HEAP_STR, userprofile_env_buf);
return puserprof; return puserprof;
} }