From 8109ffd2532aab439953a1b4f4d867d76e990870 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 7 Oct 2013 23:13:30 +0300 Subject: AGI: Fix potential buffer overrun. CID 1004028 --- engines/agi/loader_v1.cpp | 2 +- engines/agi/opcodes.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/engines/agi/loader_v1.cpp b/engines/agi/loader_v1.cpp index 33e956af41..3b862ed91f 100644 --- a/engines/agi/loader_v1.cpp +++ b/engines/agi/loader_v1.cpp @@ -202,7 +202,7 @@ int AgiLoader_v1::loadResource(int t, int n) { uint8 *data = NULL; debugC(3, kDebugLevelResources, "(t = %d, n = %d)", t, n); - if (n > MAX_DIRS) + if (n >= MAX_DIRS) return errBadResource; switch (t) { diff --git a/engines/agi/opcodes.cpp b/engines/agi/opcodes.cpp index 807ab2dc2c..d893e44c12 100644 --- a/engines/agi/opcodes.cpp +++ b/engines/agi/opcodes.cpp @@ -367,6 +367,18 @@ void AgiEngine::setupOpcodes() { logicNamesTest = insV2Test; logicNamesCmd = insV2; + + // Alter opcode parameters for specific games + // TODO: This could be either turned into a game feature, or a version + // specific check, instead of a game version check + + // The Apple IIGS versions of MH1 and Goldrush both have a parameter for + // show.mouse and hide.mouse. Fixes bugs #3577754 and #3426946. + if ((getGameID() == GID_MH1 || getGameID() == GID_GOLDRUSH) && + getPlatform() == Common::kPlatformApple2GS) { + logicNamesCmd[176].args = "n"; // hide.mouse + logicNamesCmd[178].args = "n"; // show.mouse + } } else { for (int i = 0; i < ARRAYSIZE(insV1Test); ++i) _agiCondCommands[i] = insV1Test[i].func; @@ -376,18 +388,6 @@ void AgiEngine::setupOpcodes() { logicNamesTest = insV1Test; logicNamesCmd = insV1; } - - // Alter opcode parameters for specific games - // TODO: This could be either turned into a game feature, or a version - // specific check, instead of a game version check - - // The Apple IIGS versions of MH1 and Goldrush both have a parameter for - // show.mouse and hide.mouse. Fixes bugs #3577754 and #3426946. - if ((getGameID() == GID_MH1 || getGameID() == GID_GOLDRUSH) && - getPlatform() == Common::kPlatformApple2GS) { - logicNamesCmd[176].args = "n"; // hide.mouse - logicNamesCmd[178].args = "n"; // show.mouse - } } } -- cgit v1.2.3