From b1c3332fddbb16838f1a654d6fe35ddbe09bd051 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 24 Nov 2016 20:49:24 -0600 Subject: SCI: Use strnlen instead of strlen to avoid buffer overflows --- engines/sci/parser/vocabulary.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sci/parser') diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index a0f958167d..67197fc29f 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -208,7 +208,7 @@ bool Vocabulary::loadSuffixes() { suffix_t suffix; suffix.alt_suffix = (const char *)resource->data + seeker; - suffix.alt_suffix_length = strlen(suffix.alt_suffix); + suffix.alt_suffix_length = Common::strnlen(suffix.alt_suffix, resource->size - seeker); seeker += suffix.alt_suffix_length + 1; // Hit end of string suffix.result_class = (int16)READ_BE_UINT16(resource->data + seeker); @@ -218,7 +218,7 @@ bool Vocabulary::loadSuffixes() { seeker++; suffix.word_suffix = (const char *)resource->data + seeker; - suffix.word_suffix_length = strlen(suffix.word_suffix); + suffix.word_suffix_length = Common::strnlen(suffix.word_suffix, resource->size - seeker); seeker += suffix.word_suffix_length + 1; suffix.class_mask = (int16)READ_BE_UINT16(resource->data + seeker); @@ -288,12 +288,12 @@ bool Vocabulary::loadAltInputs() { AltInput t; t._input = data; - uint32 l = strlen(data); + uint32 l = Common::strnlen(data, data_end - data); t._inputLength = l; data += l + 1; t._replacement = data; - l = strlen(data); + l = Common::strnlen(data, data_end - data); data += l + 1; if (data < data_end && strncmp(data, t._input, t._inputLength) == 0) -- cgit v1.2.3