mirror of
https://github.com/reactos/reactos.git
synced 2024-08-19 18:02:55 +00:00
[ADVAPI32]
- SEH-ize access to the data buffer in RegSetValueExW. Fixes winetest crash svn path=/trunk/; revision=58914
This commit is contained in:
parent
816d5dc335
commit
3d8186b866
|
@ -14,6 +14,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <advapi32.h>
|
#include <advapi32.h>
|
||||||
|
#include <pseh/pseh2.h>
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
||||||
|
|
||||||
/* DEFINES ******************************************************************/
|
/* DEFINES ******************************************************************/
|
||||||
|
@ -4952,10 +4953,29 @@ RegSetValueExW(HKEY hKey,
|
||||||
DWORD cbData)
|
DWORD cbData)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ValueName;
|
UNICODE_STRING ValueName;
|
||||||
PUNICODE_STRING pValueName;
|
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (is_string(dwType) && (cbData != 0))
|
||||||
|
{
|
||||||
|
PWSTR pwsData = (PWSTR)lpData;
|
||||||
|
|
||||||
|
_SEH2_TRY
|
||||||
|
{
|
||||||
|
if((pwsData[cbData / sizeof(WCHAR) - 1] != L'\0') &&
|
||||||
|
(pwsData[cbData / sizeof(WCHAR)] == L'\0'))
|
||||||
|
{
|
||||||
|
/* Increment length if last character is not zero and next is zero */
|
||||||
|
cbData += sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
_SEH2_YIELD(return ERROR_NOACCESS);
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
}
|
||||||
|
|
||||||
Status = MapDefaultKey(&KeyHandle,
|
Status = MapDefaultKey(&KeyHandle,
|
||||||
hKey);
|
hKey);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -4964,22 +4984,9 @@ RegSetValueExW(HKEY hKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitUnicodeString(&ValueName, lpValueName);
|
RtlInitUnicodeString(&ValueName, lpValueName);
|
||||||
pValueName = &ValueName;
|
|
||||||
|
|
||||||
if (is_string(dwType) && (cbData != 0))
|
|
||||||
{
|
|
||||||
PWSTR pwsData = (PWSTR)lpData;
|
|
||||||
|
|
||||||
if((pwsData[cbData / sizeof(WCHAR) - 1] != L'\0') &&
|
|
||||||
(pwsData[cbData / sizeof(WCHAR)] == L'\0'))
|
|
||||||
{
|
|
||||||
/* Increment length if last character is not zero and next is zero */
|
|
||||||
cbData += sizeof(WCHAR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = NtSetValueKey(KeyHandle,
|
Status = NtSetValueKey(KeyHandle,
|
||||||
pValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
dwType,
|
dwType,
|
||||||
(PVOID)lpData,
|
(PVOID)lpData,
|
||||||
|
|
Loading…
Reference in a new issue