mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/CrashHandler: Fix char[] without '\0' handling
Fix char[] without a NULL character '\0' in the array reading over the char[] bounds
(cherry picked from commit fd844e3d7e)
This commit is contained in:
@@ -1068,7 +1068,7 @@ bool logChildren)
|
||||
{
|
||||
case btChar:
|
||||
case btStdString:
|
||||
FormatOutputValue(buffer, basicType, length, (PVOID)offset, sizeof(buffer));
|
||||
FormatOutputValue(buffer, basicType, length, (PVOID)offset, sizeof(buffer), elementsCount);
|
||||
symbolDetails.top().Value = buffer;
|
||||
break;
|
||||
default:
|
||||
@@ -1196,7 +1196,8 @@ void WheatyExceptionReport::FormatOutputValue(char * pszCurrBuffer,
|
||||
BasicType basicType,
|
||||
DWORD64 length,
|
||||
PVOID pAddress,
|
||||
size_t bufferSize)
|
||||
size_t bufferSize,
|
||||
size_t countOverride)
|
||||
{
|
||||
__try
|
||||
{
|
||||
@@ -1204,10 +1205,15 @@ size_t bufferSize)
|
||||
{
|
||||
case btChar:
|
||||
{
|
||||
if (strlen((char*)pAddress) > bufferSize - 6)
|
||||
// Special case handling for char[] type
|
||||
if (countOverride != 0)
|
||||
length = countOverride;
|
||||
else
|
||||
length = strlen((char*)pAddress);
|
||||
if (length > bufferSize - 6)
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s...\"", bufferSize - 6, (char*)pAddress);
|
||||
else
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "\"%s\"", (char*)pAddress);
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer, "\"%.*s\"", length, (char*)pAddress);
|
||||
break;
|
||||
}
|
||||
case btStdString:
|
||||
|
||||
@@ -172,7 +172,7 @@ class WheatyExceptionReport
|
||||
|
||||
static char * DumpTypeIndex(char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool &, const char*, char*, bool, bool);
|
||||
|
||||
static void FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize);
|
||||
static void FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress, size_t bufferSize, size_t countOverride = 0);
|
||||
|
||||
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
|
||||
static DWORD_PTR DereferenceUnsafePointer(DWORD_PTR address);
|
||||
|
||||
Reference in New Issue
Block a user