PATCH: long registry lines loading
Marcus Meissner
marcus at jet.franken.de
Sun Nov 20 10:45:13 CST 2005
Hi,
When loading a registry file with an entry like:
[System\\CurrentControlSet\\HardwareProfiles\\Currentxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 1088343238
(created by a program) current WINE aborts with:
Line 44423: Key is too long '[System\\CurrentControlSet\\HardwareProfiles\\Currentxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 1088343238'
Line 44423: Error creating key '[System\\CurrentControlSet\\HardwareProfiles\\Currentxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 1088343238'
wineserver: loading /home/marcus/.wine/system.reg failed with error 80000005
wine client error:0: recvmsg: Connection reset by peer
I have this patch proposal, but I fear it might not fly with Alexandre ;)
Ciao, Marcus
Changelog:
Load registry entries longer than MAX_PATH characters.
Index: server/registry.c
===================================================================
RCS file: /home/wine/wine/server/registry.c,v
retrieving revision 1.81
diff -u -r1.81 registry.c
--- server/registry.c 9 Aug 2005 10:37:50 -0000 1.81
+++ server/registry.c 20 Nov 2005 16:40:06 -0000
@@ -335,17 +335,20 @@
/* returns a pointer to a static buffer, so only useable once per request */
static WCHAR *copy_path( const WCHAR *path, size_t len, int skip_root )
{
- static WCHAR buffer[MAX_PATH+1];
+ WCHAR *buffer = NULL;
static const WCHAR root_name[] = { '\\','R','e','g','i','s','t','r','y','\\',0 };
- if (len > sizeof(buffer)-sizeof(buffer[0]))
- {
+ buffer = (WCHAR*)malloc( len + sizeof(WCHAR) );
+ if (!buffer) {
set_error( STATUS_BUFFER_OVERFLOW );
return NULL;
}
memcpy( buffer, path, len );
buffer[len / sizeof(WCHAR)] = 0;
- if (skip_root && !strncmpiW( buffer, root_name, 10 )) return buffer + 10;
+ if (skip_root && !strncmpiW( buffer, root_name, 10 )) {
+ memcpy(buffer,path+10*sizeof(WCHAR),len-10*sizeof(WCHAR));
+ buffer[(len-10) / sizeof(WCHAR)] = 0;
+ }
return buffer;
}
@@ -1140,6 +1143,7 @@
{
WCHAR *p, *name;
int res, len, modif;
+ struct key *newkey;
len = strlen(buffer) * sizeof(WCHAR);
if (!get_file_tmp_space( info, len )) return NULL;
@@ -1169,7 +1173,9 @@
file_read_error( "Key is too long", info );
return NULL;
}
- return create_key( base, name, NULL, flags, modif, &res );
+ newkey = create_key( base, name, NULL, flags, modif, &res );
+ free( name );
+ return newkey;
}
/* parse a comma-separated list of hex digits */
@@ -1448,7 +1454,7 @@
static const WCHAR root_name[] = { 0 };
static const WCHAR HKLM[] = { 'M','a','c','h','i','n','e' };
static const WCHAR HKU_default[] = { 'U','s','e','r','\\','.','D','e','f','a','u','l','t' };
- WCHAR *current_user_path;
+ WCHAR *current_user_path, *tmppath;
const char *config = wine_get_config_dir();
char *p, *filename;
@@ -1465,19 +1471,20 @@
/* load system.reg into Registry\Machine */
- if (!(key = create_key( root_key, copy_path( HKLM, sizeof(HKLM), 0 ),
- NULL, 0, time(NULL), &dummy )))
+ tmppath = copy_path( HKLM, sizeof(HKLM), 0 );
+ if (!(key = create_key( root_key, tmppath, NULL, 0, time(NULL), &dummy )))
fatal_error( "could not create Machine registry key\n" );
-
+ free( tmppath );
strcpy( p, "/system.reg" );
load_init_registry_from_file( filename, key );
release_object( key );
/* load userdef.reg into Registry\User\.Default */
- if (!(key = create_key( root_key, copy_path( HKU_default, sizeof(HKU_default), 0 ),
- NULL, 0, time(NULL), &dummy )))
+ tmppath = copy_path( HKU_default, sizeof(HKU_default), 0 );
+ if (!(key = create_key( root_key, tmppath, NULL, 0, time(NULL), &dummy )))
fatal_error( "could not create User\\.Default registry key\n" );
+ free( tmppath );
strcpy( p, "/userdef.reg" );
load_init_registry_from_file( filename, key );
@@ -1718,6 +1725,7 @@
}
release_object( parent );
}
+ free( name );
}
/* open a registry key */
@@ -1734,6 +1742,7 @@
WCHAR *name = copy_path( get_req_data(), get_req_data_size(), !req->parent );
if (name && (key = open_key( parent, name )))
{
+ free( name );
reply->hkey = alloc_handle( current->process, key, access, 0 );
release_object( key );
}
@@ -1792,6 +1801,7 @@
set_value( key, name, req->type, data, datalen );
release_object( key );
}
+ free( name );
}
/* retrieve the value of a registry key */
@@ -1807,6 +1817,7 @@
get_value( key, name, &reply->type, &reply->total );
release_object( key );
}
+ free( name );
}
/* enumerate the value of a registry key */
@@ -1866,6 +1877,7 @@
load_registry( key, req->file );
release_object( key );
}
+ free( name );
release_object( parent );
}
}
More information about the wine-patches
mailing list