- Don't use sizeof for a variable-length structure
- Fix string buffer building
svn path=/trunk/; revision=53410
PEVENTLOGRECORD pRec;
SYSTEMTIME SysTime;
WCHAR *str;
PEVENTLOGRECORD pRec;
SYSTEMTIME SysTime;
WCHAR *str;
PBYTE Buffer;
dwRecSize =
PBYTE Buffer;
dwRecSize =
- Buffer = (BYTE *) HeapAlloc(MyHeap, HEAP_ZERO_MEMORY, dwRecSize);
+ Buffer = HeapAlloc(MyHeap, HEAP_ZERO_MEMORY, dwRecSize);
pRec->EventID = dwEventId;
pRec->EventType = wType;
pRec->EventID = dwEventId;
pRec->EventType = wType;
- pRec->NumStrings = wNumStrings;
pRec->EventCategory = wCategory;
pos = sizeof(EVENTLOGRECORD);
pRec->EventCategory = wCategory;
pos = sizeof(EVENTLOGRECORD);
}
pRec->StringOffset = pos;
}
pRec->StringOffset = pos;
- for (i = 0, str = lpStrings, nStrings = 0; i < wNumStrings; i++)
+ for (i = 0, str = lpStrings; i < wNumStrings; i++)
{
lstrcpyW((WCHAR *) (Buffer + pos), str);
pos += (lstrlenW(str) + 1) * sizeof(WCHAR);
str += lstrlenW(str) + 1;
{
lstrcpyW((WCHAR *) (Buffer + pos), str);
pos += (lstrlenW(str) + 1) * sizeof(WCHAR);
str += lstrlenW(str) + 1;
- pRec->NumStrings = nStrings;
+ pRec->NumStrings = wNumStrings;
pRec->DataOffset = pos;
if (dwDataSize)
pRec->DataOffset = pos;
if (dwDataSize)
DWORD lastRec;
DWORD recSize;
DWORD dwStringsSize = 0;
DWORD lastRec;
DWORD recSize;
DWORD dwStringsSize = 0;
+ DWORD dwUserSidLength = 0;
DWORD dwError = ERROR_SUCCESS;
WCHAR *lpStrings;
int pos = 0;
DWORD dwError = ERROR_SUCCESS;
WCHAR *lpStrings;
int pos = 0;
DPRINT1("Type %hu: %wZ\n", EventType, Strings[i]);
break;
}
DPRINT1("Type %hu: %wZ\n", EventType, Strings[i]);
break;
}
- dwStringsSize += (wcslen(Strings[i]->Buffer) + 1) * sizeof(WCHAR);
+ dwStringsSize += Strings[i]->Length + sizeof UNICODE_NULL;
- lpStrings = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, dwStringsSize * 2);
+ lpStrings = HeapAlloc(GetProcessHeap(), 0, dwStringsSize);
if (!lpStrings)
{
DPRINT1("Failed to allocate heap\n");
if (!lpStrings)
{
DPRINT1("Failed to allocate heap\n");
for (i = 0; i < NumStrings; i++)
{
for (i = 0; i < NumStrings; i++)
{
- wcscpy((WCHAR*)(lpStrings + pos), Strings[i]->Buffer);
- pos += (wcslen(Strings[i]->Buffer) + 1) * sizeof(WCHAR);
+ CopyMemory(lpStrings + pos, Strings[i]->Buffer, Strings[i]->Length);
+ pos += Strings[i]->Length / sizeof(WCHAR);
+ lpStrings[pos] = UNICODE_NULL;
+ pos += sizeof UNICODE_NULL / sizeof(WCHAR);
+ if (UserSID)
+ dwUserSidLength = FIELD_OFFSET(SID, SubAuthority[UserSID->SubAuthorityCount]);
LogBuffer = LogfAllocAndBuildNewRecord(&recSize,
lastRec,
EventType,
LogBuffer = LogfAllocAndBuildNewRecord(&recSize,
lastRec,
EventType,
EventID,
lpLogHandle->szName,
ComputerName->Buffer,
EventID,
lpLogHandle->szName,
ComputerName->Buffer,
- sizeof(RPC_SID),
- &UserSID,
+ dwUserSidLength,
+ UserSID,