aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/parser
diff options
context:
space:
mode:
authorColin Snover2016-11-24 20:49:24 -0600
committerColin Snover2017-02-05 10:24:02 -0600
commitb1c3332fddbb16838f1a654d6fe35ddbe09bd051 (patch)
tree430c757d7e323a68e8aee446932adfb9ea681adf /engines/sci/parser
parenta44720e565a2456ebc2f054af9751d109bd3f5fd (diff)
downloadscummvm-rg350-b1c3332fddbb16838f1a654d6fe35ddbe09bd051.tar.gz
scummvm-rg350-b1c3332fddbb16838f1a654d6fe35ddbe09bd051.tar.bz2
scummvm-rg350-b1c3332fddbb16838f1a654d6fe35ddbe09bd051.zip
SCI: Use strnlen instead of strlen to avoid buffer overflows
Diffstat (limited to 'engines/sci/parser')
-rw-r--r--engines/sci/parser/vocabulary.cpp8
1 files changed, 4 insertions, 4 deletions
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)