From: Alexandre Julliard julliard@winehq.org
This makes it possible to override large variables through the registry. --- dlls/ntdll/unix/env.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index fdc71e296c2..5cdbef77caa 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -848,7 +848,7 @@ static const char overrides_help_message[] = * * Return the initial environment. */ -static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) +static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size, BOOL skip_unix ) { char **e; WCHAR *env, *ptr, *end; @@ -857,13 +857,6 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) *size = 1; for (e = environ; *e; e++) *size += strlen(*e) + 6;
- if (*size > 30000) /* Windows is limited to 32767, and we need some space for the Wine variables */ - { - ERR( "Unix environment too large, not importing it.\n"); - *size = *pos = 0; - return NULL; - } - env = malloc( *size * sizeof(WCHAR) ); ptr = env; end = env + *size - 1; @@ -881,6 +874,7 @@ static WCHAR *get_initial_environment( SIZE_T *pos, SIZE_T *size ) exit(0); } } + else if (skip_unix) continue; else if (host_var_exists( str )) continue; else if (is_special_env_var( str )) /* prefix it with WINE_HOST_ */ { @@ -1882,7 +1876,7 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) RTL_USER_PROCESS_PARAMETERS *params = NULL; SIZE_T size, env_pos, env_size; WCHAR *dst, *cmdline, *path, *bootstrap; - WCHAR *env = get_initial_environment( &env_pos, &env_size ); + WCHAR *env = get_initial_environment( &env_pos, &env_size, FALSE ); WCHAR *curdir = get_initial_directory(); UNICODE_STRING nt_name; NTSTATUS status; @@ -1906,6 +1900,14 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) is_prefix_bootstrap = !!bootstrap; free( bootstrap ); add_registry_environment( &env, &env_pos, &env_size ); + if (env_pos >= 32767) /* Windows used to have a size limit, and some apps depend on it */ + { + ERR( "Unix environment too large, not importing it.\n"); + free( env ); + env = get_initial_environment( &env_pos, &env_size, TRUE ); + add_dynamic_environment( &env, &env_pos, &env_size ); + add_registry_environment( &env, &env_pos, &env_size ); + } env[env_pos++] = 0;
get_full_path( main_argv[1], curdir, &nt_name );