bugfix: fix overflow risk of strlen function

This commit is contained in:
Hong, Yang A 2022-04-28 10:11:32 +00:00
parent 1baf340d1c
commit 47bc68339f

View File

@ -323,7 +323,8 @@ void addExpression(NG &ng, unsigned index, const char *expression,
}
// Ensure that our pattern isn't too long (in characters).
if (strlen(expression) > cc.grey.limitPatternLength) {
size_t maxlen = cc.grey.limitPatternLength + 1;
if (strnlen(expression, maxlen) >= maxlen) {
throw CompileError("Pattern length exceeds limit.");
}