mirror of
https://github.com/reactos/reactos.git
synced 2024-07-03 03:04:22 +00:00
[WIN32K]
- Fix possible buffer overrun - Use KEY_VALUE_PARTIAL_INFORMATION field instead of magic offset to data svn path=/trunk/; revision=53645
This commit is contained in:
parent
6a2bccb41c
commit
dd187dbf32
|
@ -286,6 +286,9 @@ PKBL W32kGetDefaultKeyLayout(VOID)
|
||||||
|
|
||||||
if( NT_SUCCESS(Status) )
|
if( NT_SUCCESS(Status) )
|
||||||
{
|
{
|
||||||
|
FullKeyboardLayoutPath.Buffer = wszBuffer;
|
||||||
|
FullKeyboardLayoutPath.MaximumLength = sizeof(wszBuffer);
|
||||||
|
|
||||||
// FIXME: Is this 100% correct?
|
// FIXME: Is this 100% correct?
|
||||||
// We're called very early, so HKEY_CURRENT_USER might not be available yet. Check this first.
|
// We're called very early, so HKEY_CURRENT_USER might not be available yet. Check this first.
|
||||||
InitializeObjectAttributes(&KeyAttributes, &CurrentUserPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
InitializeObjectAttributes(&KeyAttributes, &CurrentUserPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||||
|
@ -294,18 +297,18 @@ PKBL W32kGetDefaultKeyLayout(VOID)
|
||||||
if(Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
if(Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||||
{
|
{
|
||||||
// It is not available, so read it from HKEY_USERS\.DEFAULT
|
// It is not available, so read it from HKEY_USERS\.DEFAULT
|
||||||
|
FullKeyboardLayoutPath.Length = sizeof(szDefaultUserPath) - sizeof(UNICODE_NULL);
|
||||||
RtlCopyMemory(wszBuffer, szDefaultUserPath, sizeof(szDefaultUserPath));
|
RtlCopyMemory(wszBuffer, szDefaultUserPath, sizeof(szDefaultUserPath));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The path is available
|
// The path is available
|
||||||
ZwClose(KeyHandle);
|
ZwClose(KeyHandle);
|
||||||
RtlCopyMemory(wszBuffer, CurrentUserPath.Buffer, CurrentUserPath.MaximumLength);
|
RtlCopyUnicodeString(&FullKeyboardLayoutPath, &CurrentUserPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the full path
|
// Free CurrentUserPath - we dont need it anymore
|
||||||
RtlInitUnicodeString(&FullKeyboardLayoutPath, wszBuffer);
|
RtlFreeUnicodeString(&CurrentUserPath);
|
||||||
FullKeyboardLayoutPath.MaximumLength = MAX_PATH;
|
|
||||||
|
|
||||||
Status = RtlAppendUnicodeToString(&FullKeyboardLayoutPath, szKeyboardLayoutPath);
|
Status = RtlAppendUnicodeToString(&FullKeyboardLayoutPath, szKeyboardLayoutPath);
|
||||||
|
|
||||||
|
@ -326,8 +329,6 @@ PKBL W32kGetDefaultKeyLayout(VOID)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ERR("RtlAppendUnicodeToString failed! (%08lx)\n", Status);
|
ERR("RtlAppendUnicodeToString failed! (%08lx)\n", Status);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&CurrentUserPath);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ERR("RtlFormatCurrentUserKeyPath failed! (%08lx)\n", Status);
|
ERR("RtlFormatCurrentUserKeyPath failed! (%08lx)\n", Status);
|
||||||
|
|
|
@ -17,11 +17,11 @@ FASTCALL
|
||||||
IntGdiGetLanguageID(VOID)
|
IntGdiGetLanguageID(VOID)
|
||||||
{
|
{
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
ULONG Size = sizeof(WCHAR) * (MAX_PATH + 12);
|
|
||||||
OBJECT_ATTRIBUTES ObAttr;
|
OBJECT_ATTRIBUTES ObAttr;
|
||||||
// http://support.microsoft.com/kb/324097
|
// http://support.microsoft.com/kb/324097
|
||||||
ULONG Ret = 0x409; // English
|
ULONG Ret = 0x409; // English
|
||||||
PVOID KeyInfo;
|
PKEY_VALUE_PARTIAL_INFORMATION pKeyInfo;
|
||||||
|
ULONG Size = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MAX_PATH*sizeof(WCHAR);
|
||||||
UNICODE_STRING Language;
|
UNICODE_STRING Language;
|
||||||
|
|
||||||
RtlInitUnicodeString( &Language,
|
RtlInitUnicodeString( &Language,
|
||||||
|
@ -35,22 +35,22 @@ IntGdiGetLanguageID(VOID)
|
||||||
|
|
||||||
if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
|
if ( NT_SUCCESS(ZwOpenKey(&KeyHandle, KEY_READ, &ObAttr)))
|
||||||
{
|
{
|
||||||
KeyInfo = ExAllocatePoolWithTag(PagedPool, Size, TAG_STRING);
|
pKeyInfo = ExAllocatePoolWithTag(PagedPool, Size, TAG_STRING);
|
||||||
if ( KeyInfo )
|
if ( pKeyInfo )
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&Language, L"Default");
|
RtlInitUnicodeString(&Language, L"Default");
|
||||||
|
|
||||||
if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
|
if ( NT_SUCCESS(ZwQueryValueKey( KeyHandle,
|
||||||
&Language,
|
&Language,
|
||||||
KeyValuePartialInformation,
|
KeyValuePartialInformation,
|
||||||
KeyInfo,
|
pKeyInfo,
|
||||||
Size,
|
Size,
|
||||||
&Size)) )
|
&Size)) )
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&Language, (PVOID)((char *)KeyInfo + 12));
|
RtlInitUnicodeString(&Language, (PWSTR)pKeyInfo->Data);
|
||||||
RtlUnicodeStringToInteger(&Language, 16, &Ret);
|
RtlUnicodeStringToInteger(&Language, 16, &Ret);
|
||||||
}
|
}
|
||||||
ExFreePoolWithTag(KeyInfo, TAG_STRING);
|
ExFreePoolWithTag(pKeyInfo, TAG_STRING);
|
||||||
}
|
}
|
||||||
ZwClose(KeyHandle);
|
ZwClose(KeyHandle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue