Fix a write-out-of-bounds error in Json.

This commit is contained in:
Jordan Bancino 2023-02-23 03:46:05 +00:00
parent 3bbff5379f
commit 9e9b5c9cda
2 changed files with 29 additions and 15 deletions

View file

@ -424,6 +424,20 @@ JsonDecodeString(FILE * in)
switch (c) switch (c)
{ {
case '"': case '"':
if (len >= allocated)
{
char *tmp;
allocated += 1;
tmp = Realloc(str, allocated * sizeof(char));
if (!tmp)
{
Free(str);
return NULL;
}
str = tmp;
}
str[len] = '\0'; str[len] = '\0';
return str; return str;
break; break;

View file

@ -80,6 +80,21 @@ const char
"=======================================================" "======================================================="
}; };
static void
TelodendriaHexDump(size_t off, char *hexBuf, char *asciiBuf, void *args)
{
LogConfig *lc = args;
if (hexBuf && asciiBuf)
{
Log(lc, LOG_DEBUG, "%04x: %s | %s |", off, hexBuf, asciiBuf);
}
else
{
Log(lc, LOG_DEBUG, "%04x", off);
}
}
static void static void
TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args) TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
{ {
@ -112,21 +127,6 @@ TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
MemoryInfoGetPointer(i)); MemoryInfoGetPointer(i));
} }
static void
TelodendriaHexDump(size_t off, char *hexBuf, char *asciiBuf, void *args)
{
LogConfig *lc = args;
if (hexBuf && asciiBuf)
{
Log(lc, LOG_DEBUG, "%04x: %s | %s |", off, hexBuf, asciiBuf);
}
else
{
Log(lc, LOG_DEBUG, "%04x", off);
}
}
static void static void
TelodendriaMemoryIterator(MemoryInfo * i, void *args) TelodendriaMemoryIterator(MemoryInfo * i, void *args)
{ {