Skip to content
Permalink
Browse files Browse the repository at this point in the history
Prevent an invalid memory writes in compileRule
Thanks to Han Zheng for reporting it

Fixes #1214
  • Loading branch information
egli committed May 25, 2022
1 parent 83c9135 commit ff747ec
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions liblouis/compileTranslationTable.c
Expand Up @@ -3736,12 +3736,14 @@ compileRule(FileInfo *file, TranslationTableHeader **table,

case CTO_SeqAfterExpression:
if (!getRuleCharsText(file, &ruleChars)) return 0;
for ((*table)->seqAfterExpressionLength = 0;
(*table)->seqAfterExpressionLength < ruleChars.length;
(*table)->seqAfterExpressionLength++)
(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] =
ruleChars.chars[(*table)->seqAfterExpressionLength];
(*table)->seqAfterExpression[(*table)->seqAfterExpressionLength] = 0;
if ((ruleChars.length + 1) > SEQPATTERNSIZE) {
compileError(file, "More than %d characters", SEQPATTERNSIZE);
return 0;
}
for (int k = 0; k < ruleChars.length; k++)
(*table)->seqAfterExpression[k] = ruleChars.chars[k];
(*table)->seqAfterExpression[ruleChars.length] = 0;
(*table)->seqAfterExpressionLength = ruleChars.length;
return 1;

case CTO_CapsModeChars:
Expand Down

0 comments on commit ff747ec

Please sign in to comment.