summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Bird <Archez@users.noreply.github.com>2023-04-18 01:08:06 -0400
committerGitHub <noreply@github.com>2023-04-18 01:08:06 -0400
commit1eca2afec405be0b7aff6e9c2837c9141a5ea724 (patch)
tree222afbd33b0680b6dc3f73116a141e39e4fa08e2
parentdbdd2de9610f73098c0302d833b05d03633d221e (diff)
zapd fix text extraction overflowing (#2717)
-rw-r--r--ZAPD/ZText.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/ZAPD/ZText.cpp b/ZAPD/ZText.cpp
index 2e9e0f6..b024920 100644
--- a/ZAPD/ZText.cpp
+++ b/ZAPD/ZText.cpp
@@ -63,18 +63,26 @@ void ZText::ParseRawData()
unsigned int extra = 0;
bool stop = false;
+ // Continue parsing until we are told to stop and all extra bytes are read
while ((c != '\0' && !stop) || extra > 0)
{
msgEntry.msg += c;
msgPtr++;
+ // Some control codes require reading extra bytes
if (extra == 0)
{
- if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || c == 0x06 ||
+ // End marker, so stop this message and do not read anything else
+ if (c == 0x02)
+ {
+ stop = true;
+ }
+ else if (c == 0x05 || c == 0x13 || c == 0x0E || c == 0x0C || c == 0x1E || c == 0x06 ||
c == 0x14)
{
extra = 1;
}
+ // "Continue to new text ID", so stop this message and read two more bytes for the text ID
else if (c == 0x07)
{
extra = 2;