kernel32: Fixed buffer overrun in get_registry_locale_info.

This commit is contained in:
Alexandre Julliard 2006-11-09 12:03:21 +01:00
parent 6987a4b453
commit 63ca94c419
1 changed files with 10 additions and 7 deletions

View File

@ -804,7 +804,6 @@ static INT get_registry_locale_info( LPCWSTR value, LPWSTR buffer, INT len )
} }
status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, info, size, &size ); status = NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, info, size, &size );
if (status == STATUS_BUFFER_OVERFLOW && !buffer) status = 0;
if (!status) if (!status)
{ {
@ -825,14 +824,18 @@ static INT get_registry_locale_info( LPCWSTR value, LPWSTR buffer, INT len )
buffer[ret-1] = 0; buffer[ret-1] = 0;
} }
} }
else if (status == STATUS_BUFFER_OVERFLOW && !buffer)
{
ret = (size - info_size) / sizeof(WCHAR) + 1;
}
else if (status == STATUS_OBJECT_NAME_NOT_FOUND)
{
ret = -1;
}
else else
{ {
if (status == STATUS_OBJECT_NAME_NOT_FOUND) ret = -1; SetLastError( RtlNtStatusToDosError(status) );
else ret = 0;
{
SetLastError( RtlNtStatusToDosError(status) );
ret = 0;
}
} }
NtClose( hkey ); NtClose( hkey );
HeapFree( GetProcessHeap(), 0, info ); HeapFree( GetProcessHeap(), 0, info );