From dec12f5b6dca67e5d6f47579bfee5ef2d1ab7ed3 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 13 May 2017 23:42:53 -0500 Subject: SCI: Guard against potential stack overflow in vocab word parser --- engines/sci/parser/vocabulary.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index 3989f20209..2642b6bd6e 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -142,7 +142,7 @@ bool Vocabulary::loadParserWords() { if (resourceType == kVocabularySCI1) { c = 1; - while (seeker < resource->size() && currentWordPos < 255 && c) { + while (seeker < resource->size() && currentWordPos < ARRAYSIZE(currentWord) - 1 && c) { c = resource->getUint8At(seeker++); currentWord[currentWordPos++] = c; } @@ -158,6 +158,7 @@ bool Vocabulary::loadParserWords() { return false; } c = resource->getUint8At(seeker++); + assert(currentWordPos < ARRAYSIZE(currentWord) - 1); currentWord[currentWordPos++] = c & 0x7f; // 0x80 is used to terminate the string } while (c < 0x80); } -- cgit v1.2.3