]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
bugfix: fix overflow risk of strlen function
authorHong, Yang A <yang.a.hong@intel.com>
Thu, 28 Apr 2022 10:11:32 +0000 (10:11 +0000)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Mon, 29 Aug 2022 12:03:22 +0000 (15:03 +0300)
src/compiler/compiler.cpp

index ae5927bcbdbb53a01b27696f872dcbd5f07baa6d..3283683415553d58fd0ede537ce317e4cb849fa0 100644 (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.");
     }