Skip to content

Commit

Permalink
SCI: Guard against potential stack overflow in vocab word parser
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed May 14, 2017
1 parent 444b11b commit dec12f5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion engines/sci/parser/vocabulary.cpp
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit dec12f5

Please sign in to comment.