advapi32: Don't use the static Unicode buffer for value names since they can be larger than MAX_PATH.
This commit is contained in:
parent
935cc7987d
commit
acc41b50d1
|
@ -1103,6 +1103,7 @@ LSTATUS WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD typ
|
||||||
CONST BYTE *data, DWORD count )
|
CONST BYTE *data, DWORD count )
|
||||||
{
|
{
|
||||||
ANSI_STRING nameA;
|
ANSI_STRING nameA;
|
||||||
|
UNICODE_STRING nameW;
|
||||||
WCHAR *dataW = NULL;
|
WCHAR *dataW = NULL;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
|
@ -1133,10 +1134,10 @@ LSTATUS WINAPI RegSetValueExA( HKEY hkey, LPCSTR name, DWORD reserved, DWORD typ
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitAnsiString( &nameA, name );
|
RtlInitAnsiString( &nameA, name );
|
||||||
if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString,
|
if (!(status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE )))
|
||||||
&nameA, FALSE )))
|
|
||||||
{
|
{
|
||||||
status = NtSetValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString, 0, type, data, count );
|
status = NtSetValueKey( hkey, &nameW, 0, type, data, count );
|
||||||
|
RtlFreeUnicodeString( &nameW );
|
||||||
}
|
}
|
||||||
HeapFree( GetProcessHeap(), 0, dataW );
|
HeapFree( GetProcessHeap(), 0, dataW );
|
||||||
return RtlNtStatusToDosError( status );
|
return RtlNtStatusToDosError( status );
|
||||||
|
@ -1305,6 +1306,7 @@ LSTATUS WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWO
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
ANSI_STRING nameA;
|
ANSI_STRING nameA;
|
||||||
|
UNICODE_STRING nameW;
|
||||||
DWORD total_size, datalen = 0;
|
DWORD total_size, datalen = 0;
|
||||||
char buffer[256], *buf_ptr = buffer;
|
char buffer[256], *buf_ptr = buffer;
|
||||||
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
|
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
|
||||||
|
@ -1323,12 +1325,11 @@ LSTATUS WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWO
|
||||||
if (type) *type = REG_NONE;
|
if (type) *type = REG_NONE;
|
||||||
|
|
||||||
RtlInitAnsiString( &nameA, name );
|
RtlInitAnsiString( &nameA, name );
|
||||||
if ((status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString,
|
if ((status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE )))
|
||||||
&nameA, FALSE )))
|
|
||||||
return RtlNtStatusToDosError(status);
|
return RtlNtStatusToDosError(status);
|
||||||
|
|
||||||
status = NtQueryValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString,
|
status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
|
||||||
KeyValuePartialInformation, buffer, sizeof(buffer), &total_size );
|
buffer, sizeof(buffer), &total_size );
|
||||||
if (status && status != STATUS_BUFFER_OVERFLOW) goto done;
|
if (status && status != STATUS_BUFFER_OVERFLOW) goto done;
|
||||||
|
|
||||||
/* we need to fetch the contents for a string type even if not requested,
|
/* we need to fetch the contents for a string type even if not requested,
|
||||||
|
@ -1345,8 +1346,8 @@ LSTATUS WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWO
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
info = (KEY_VALUE_PARTIAL_INFORMATION *)buf_ptr;
|
info = (KEY_VALUE_PARTIAL_INFORMATION *)buf_ptr;
|
||||||
status = NtQueryValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString,
|
status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation,
|
||||||
KeyValuePartialInformation, buf_ptr, total_size, &total_size );
|
buf_ptr, total_size, &total_size );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) goto done;
|
if (status) goto done;
|
||||||
|
@ -1384,6 +1385,7 @@ LSTATUS WINAPI RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWORD reserved, LPDWO
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
|
if (buf_ptr != buffer) HeapFree( GetProcessHeap(), 0, buf_ptr );
|
||||||
|
RtlFreeUnicodeString( &nameW );
|
||||||
return RtlNtStatusToDosError(status);
|
return RtlNtStatusToDosError(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1955,15 +1957,18 @@ LSTATUS WINAPI RegDeleteValueW( HKEY hkey, LPCWSTR name )
|
||||||
*/
|
*/
|
||||||
LSTATUS WINAPI RegDeleteValueA( HKEY hkey, LPCSTR name )
|
LSTATUS WINAPI RegDeleteValueA( HKEY hkey, LPCSTR name )
|
||||||
{
|
{
|
||||||
STRING nameA;
|
ANSI_STRING nameA;
|
||||||
|
UNICODE_STRING nameW;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
|
if (!(hkey = get_special_root_hkey( hkey ))) return ERROR_INVALID_HANDLE;
|
||||||
|
|
||||||
RtlInitAnsiString( &nameA, name );
|
RtlInitAnsiString( &nameA, name );
|
||||||
if (!(status = RtlAnsiStringToUnicodeString( &NtCurrentTeb()->StaticUnicodeString,
|
if (!(status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE )))
|
||||||
&nameA, FALSE )))
|
{
|
||||||
status = NtDeleteValueKey( hkey, &NtCurrentTeb()->StaticUnicodeString );
|
status = NtDeleteValueKey( hkey, &nameW );
|
||||||
|
RtlFreeUnicodeString( &nameW );
|
||||||
|
}
|
||||||
return RtlNtStatusToDosError( status );
|
return RtlNtStatusToDosError( status );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1968,7 +1968,8 @@ static void test_delete_value(void)
|
||||||
memset(longname, 'a', 400);
|
memset(longname, 'a', 400);
|
||||||
longname[400] = 0;
|
longname[400] = 0;
|
||||||
res = RegDeleteValueA( hkey_main, longname );
|
res = RegDeleteValueA( hkey_main, longname );
|
||||||
todo_wine ok(res == ERROR_FILE_NOT_FOUND, "expect ERROR_FILE_NOT_FOUND, got %i\n", res);
|
ok(res == ERROR_FILE_NOT_FOUND || broken(res == ERROR_MORE_DATA), /* nt4, win2k */
|
||||||
|
"expect ERROR_FILE_NOT_FOUND, got %i\n", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(registry)
|
START_TEST(registry)
|
||||||
|
|
Loading…
Reference in New Issue