From: Hong, Yang A Date: Thu, 28 Apr 2022 10:11:32 +0000 (+0000) Subject: bugfix: fix overflow risk of strlen function X-Git-Tag: vectorscan/5.4.8~1^2~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d4940dfbe523589e4ea90033bda4c574c73d627;p=thirdparty%2Fvectorscan.git bugfix: fix overflow risk of strlen function --- diff --git a/src/compiler/compiler.cpp b/src/compiler/compiler.cpp index ae5927bc..32836834 100644 --- a/src/compiler/compiler.cpp +++ b/src/compiler/compiler.cpp @@ -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."); }